Apr 12, 2004 #1 ghost2 Programmer Joined Aug 7, 2003 Messages 145 Location 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?
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?
Apr 12, 2004 #2 MartinCroft Programmer Joined Jun 12, 2003 Messages 151 Location GB 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 Upvote 0 Downvote
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