Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to specify single quote in string

Author  Topic 

cjcclee
Starting Member

33 Posts

Posted - 2008-09-19 : 11:50:55

I could not fingure it out. for example ,

I have simple store procedure,

create sp_test

@Parm1 varchar(100)

as

select * from table1
where field1 in ('+ @Parm1 +')


what I need do is: select * from table1 where field in ('a','b')

when I exec store procedure, how should I specify parm1,

exec sp_test 'a,b', the result is not correct.

and I try exec sp_test '''a'',''b''', the result is not correct.

how should I specify it in the store procedure, and how to exec it? Thanks!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-19 : 13:02:49
[code]create sp_test

@Parm1 varchar(100)

as

select * from table1
where ',' + @Parm1 +',' like '%,'+field1+',%'[/code]
Go to Top of Page

cjcclee
Starting Member

33 Posts

Posted - 2008-09-19 : 13:55:38
quote:
Originally posted by visakh16

create sp_test

@Parm1 varchar(100)

as

select * from table1
where ',' + @Parm1 +',' like '%,'+field1+',%'





Thanks so much for your reply! It works. I appreciated your help.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-20 : 02:01:24
Also search for Array+SQL Server in google

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -