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 2000 Forums
 SQL Server Development (2000)
 Escaping special characters in Dynamic SQL

Author  Topic 

ddasilva99
Starting Member

26 Posts

Posted - 2006-11-18 : 15:20:52
Hi everyone,

How do I escape special characters in a dynamic SQL statement?
For instance @name = "Derek's Test"

Thanks,
D

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-11-18 : 15:24:29
instead of one ' put 2 '
select @name = 'Derek''s Test'




Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2006-11-18 : 15:28:13
this question makes me think you are not too familiar with dynamic sql.

please read this before putting your dynamic sql into production:

http://sommarskog.se/dynamic_sql.html


SqlSpec - a fast, cheap, and comprehensive data dictionary generator for
SQL Server 2000/2005 and Analysis Server 2005 - http://www.elsasoft.org
Go to Top of Page
   

- Advertisement -