Click here to Skip to main content
15,867,308 members
Home / Discussions / Database
   

Database

 
QuestionWhat is code for log_In in ASP Pin
Phumlani Kunene24-Jun-09 3:49
Phumlani Kunene24-Jun-09 3:49 
AnswerRe: What is code for log_In in ASP Pin
J4amieC24-Jun-09 5:51
J4amieC24-Jun-09 5:51 
AnswerRe: What is code for log_In in ASP Pin
Jerry Hammond24-Jun-09 6:27
Jerry Hammond24-Jun-09 6:27 
AnswerRe: What is code for log_In in ASP Pin
Niladri_Biswas24-Jun-09 18:52
Niladri_Biswas24-Jun-09 18:52 
QuestionProblem when creating query on base of combination Pin
Rupesh Kumar Swami24-Jun-09 0:00
Rupesh Kumar Swami24-Jun-09 0:00 
AnswerRe: Problem when creating query on base of combination Pin
Syed Mehroz Alam24-Jun-09 1:11
Syed Mehroz Alam24-Jun-09 1:11 
GeneralRe: Problem when creating query on base of combination Pin
Rupesh Kumar Swami24-Jun-09 1:45
Rupesh Kumar Swami24-Jun-09 1:45 
AnswerRe: Problem when creating query on base of combination [modified] Pin
Niladri_Biswas24-Jun-09 2:16
Niladri_Biswas24-Jun-09 2:16 
Dear Rupesh,

As I don't have MS Access in my system.

So I was forced to solve the problem in SQL Server 2005. But the syntax will remain same in both the cases(or may be minor changes which I hope you can do).

I have created a table[TBLSEARCH] with the following values

a
b
c
 a
 b
 c
AC
AD
 AD
AE
 AE
AF
 AF
       AFGTHY
BE
 BE


And my Stored Proc goes like this

ALTER PROCEDURE sp_Search
	-- Add the parameters for the stored procedure here
	(@SEARCHSTRING VARCHAR(50))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- SEARCH WITH ABC COMBINATION
	IF(UPPER(@SEARCHSTRING) = 'ABC')

		BEGIN
			
			SELECT * 
			FROM TBLSEARCH WHERE RTRIM(LTRIM(NAME)) LIKE '[A-C]%'

		END

	-- SEARCH WITH DEF COMBINATION
	IF(UPPER(@SEARCHSTRING) = 'DEF')

		BEGIN
			
			SELECT * 
			FROM TBLSEARCH WHERE 

				RTRIM(LTRIM(NAME)) LIKE 'A[DEF]%' OR

				RTRIM(LTRIM(NAME)) LIKE 'B[DEF]%' OR

				RTRIM(LTRIM(NAME)) LIKE 'C[DEF]%'

		END

	-- SEARCH WITH GHI COMBINATION
	IF(UPPER(@SEARCHSTRING) = 'GHI')

		BEGIN
			
			SELECT * 
			FROM TBLSEARCH WHERE 

				RTRIM(LTRIM(NAME)) LIKE 'A[DEF][GHI]%' OR

				RTRIM(LTRIM(NAME)) LIKE 'B[DEF][GHI]%' OR

				RTRIM(LTRIM(NAME)) LIKE 'C[DEF][GHI]%'

		END

END
GO



N.B.~ The @SEARCHSTRING can assume values either 'ABC' or 'DEF' or 'GHI' [ As your button names ]

In my system I am getting the correct output.

Please check it and let me know if it is working as per your expectation or not.

Regards,
Niladri Biswas
Smile | :)

Niladri Biswas

modified on Wednesday, June 24, 2009 8:40 AM

GeneralRe: Problem when creating query on base of combination Pin
J4amieC24-Jun-09 2:21
J4amieC24-Jun-09 2:21 
GeneralRe: Problem when creating query on base of combination Pin
Niladri_Biswas24-Jun-09 2:23
Niladri_Biswas24-Jun-09 2:23 
GeneralRe: Problem when creating query on base of combination Pin
Rupesh Kumar Swami3-Jul-09 6:08
Rupesh Kumar Swami3-Jul-09 6:08 
QuestionSQL proxy server Pin
Maddie from Dartford23-Jun-09 19:58
Maddie from Dartford23-Jun-09 19:58 
AnswerRe: SQL proxy server Pin
_Damian S_23-Jun-09 20:13
professional_Damian S_23-Jun-09 20:13 
QuestionMoney or Decimal datatype? Pin
VisualLive23-Jun-09 16:29
VisualLive23-Jun-09 16:29 
AnswerRe: Money or Decimal datatype? [modified] Pin
Niladri_Biswas23-Jun-09 17:25
Niladri_Biswas23-Jun-09 17:25 
GeneralRe: Money or Decimal datatype? Pin
VisualLive23-Jun-09 18:19
VisualLive23-Jun-09 18:19 
GeneralRe: Money or Decimal datatype? Pin
Niladri_Biswas23-Jun-09 18:21
Niladri_Biswas23-Jun-09 18:21 
QuestionHelp in deploying program with database attached Pin
galil45023-Jun-09 10:13
galil45023-Jun-09 10:13 
AnswerRe: Help in deploying program with database attached Pin
Niladri_Biswas24-Jun-09 2:58
Niladri_Biswas24-Jun-09 2:58 
AnswerRe: Help in deploying program with database attached Pin
galil45024-Jun-09 6:01
galil45024-Jun-09 6:01 
QuestionRe: Help in deploying program with database attached Pin
Kschuler24-Jun-09 7:40
Kschuler24-Jun-09 7:40 
AnswerRe: Help in deploying program with database attached Pin
galil45024-Jun-09 7:44
galil45024-Jun-09 7:44 
GeneralRe: Help in deploying program with database attached Pin
Kschuler24-Jun-09 8:00
Kschuler24-Jun-09 8:00 
QuestionHow to select records 11 to 20 in SQL SERVER? Pin
pankazmittal23-Jun-09 5:32
pankazmittal23-Jun-09 5:32 
AnswerRe: How to select records 11 to 20 in SQL SERVER? Pin
Giorgi Dalakishvili23-Jun-09 6:53
mentorGiorgi Dalakishvili23-Jun-09 6:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.