Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

quotation mark 2

Status
Not open for further replies.

wg26

Programmer
Mar 21, 2002
135
US
Hi Everyone:

I am trying to put a quotation mark on a variable, and I did as the following:
@SQL = 'select ....from....
where [Detail].[Detail Name] = ' + ''' + @DetailName + '''

but it does not work. and Can one please kindly tell me how to put quotation mark around a variable? thanks alot
 
I think this will work....

@SQL = 'select ....from....
where [Detail].[Detail Name] = ''' + @DetailName + '''' Get the Best Answers! faq333-2924
"A witty saying proves nothing." - Voltaire
mikewolf@tst-us.com
 
Hi,

Try this


declare @SQL varchar(2000)
declare @detailname varchar(100)

set @detailname ='gg'

set @SQL = 'select * from tbl
where [Detail].[Detail Name] = ''' + @DetailName + ''''

print @sql



Sunil
 
Function QUOTENAME should work. If not try playing around with SET QUOTED_IDENTIFIER ON/OFF so you can use double quotes.
Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top