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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exec Command Stored Procedure

Status
Not open for further replies.

ghost2

Programmer
Aug 7, 2003
145
US
How do you surround a single quote in an exec command to get it to stay as a single quote and not close the string?
 
Hi

if your building dynamic sql within a string and want ' to be displayed as ' then add addtional ''

E.G

DECLARE @test varchar(100)
DECLARE @text varchar(100)

SET @text='microsoft'

SET @test ='Select * from orders where company = ' +
'''' +@text+''''

PRINT @test
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top