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 2005 Forums
 Transact-SQL (2005)
 single quotes in procedure

Author  Topic 

desikankannan
Posting Yak Master

152 Posts

Posted - 2010-03-05 : 12:56:00
hi,
i try to write a procedure

reate procedure commandata
(
@slot varchar(15),
@location varchar(15),
@frequency varchar(15)

)
as

select desckey,descvalue,desccategory from mst_desc where desccategory in(''@slot'',''@location'',''@frequency'') order by desckey


i got the error
Incorrect syntax near '@slot'.
i think problem near ''@slot''


Desikankannan

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-05 : 12:58:32
you dont quotes at all

this is enough

select desckey,descvalue,desccategory from mst_desc where desccategory in(@slot,@location,@frequency) order by desckey

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

DP978
Constraint Violating Yak Guru

269 Posts

Posted - 2010-03-05 : 12:58:53
Pretty sure you need 3" ' " s

'''@slot'''

Viskah may be right, but from his previous posts I thought he had built this one dynamically. Sorry :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-05 : 13:06:57
quote:
Originally posted by DP978

Pretty sure you need 3" ' " s

'''@slot'''

Viskah may be right, but from his previous posts I thought he had built this one dynamically. Sorry :)


then you would require ''' before and after concatenation

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -