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
 General SQL Server Forums
 New to SQL Server Programming
 NEW TO SQL

Author  Topic 

mavershang
Posting Yak Master

111 Posts

Posted - 2009-05-20 : 15:20:13
Hi all. Here is my rookie question:

SET @SQL='
SELECT '' AS T
FROM table
;'

EXEC (@SQL)

Now the question is how could I use that '' inside a ''.

Thanks

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-05-20 : 15:29:51
[code]SET @SQL='
SELECT '''' AS T
FROM table
;'

EXEC (@SQL)[/code]Simply double the apostrophes when embedded in a string value.
Go to Top of Page

mavershang
Posting Yak Master

111 Posts

Posted - 2009-05-20 : 15:43:08
Thanks a lot

quote:
Originally posted by robvolk

SET @SQL='
SELECT '''' AS T
FROM table
;'

EXEC (@SQL)
Simply double the apostrophes when embedded in a string value.

Go to Top of Page
   

- Advertisement -