By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,379 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,379 IT Pros & Developers. It's quick & easy.

sql server stored procedure

P: 81
Hi,
i writen stored procedure for getting values based on location but my problem is if i entered single location means its working but if i enteres multi location means its not working
ex: if i entered Chennai means its working then if i entered Chennai,Bangalore means its not working???

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Get]
@ID varchar(500)=NULL,
@Location varchar(50)=NULL
AS
BEGIN
select * from Details where Location in (@Location)
End
May 12 '08 #1
Share this Question
Share on Google+
2 Replies


deepuv04
Expert 100+
P: 227
Hi,
i writen stored procedure for getting values based on location but my problem is if i entered single location means its working but if i enteres multi location means its not working
ex: if i entered Chennai means its working then if i entered Chennai,Bangalore means its not working???

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Get]
@ID varchar(500)=NULL,
@Location varchar(50)=NULL
AS
BEGIN
select * from Details where Location in (@Location)
End
Hi
Try the following code...
Here pass the @Location value like Banglore,Chennai,....

[code = sql]
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Get]
@ID varchar(500)=NULL,
@Location varchar(50)=NULL
AS
BEGIN
select * from Details
where (','+isnull(@Location,convert(varchar(100),Locatio n) )+',') like
('%,'+convert(varchar(20),Location)+ ',%')

End

[/code]

Thanks
May 12 '08 #2

P: 81
Hi, Deepu!
Thanx for reply!, Its Working
May 13 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.