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
 Transact-SQL (2000)
 quotation mark in stored procedure

Author  Topic 

kolesnik
Starting Member

8 Posts

Posted - 2005-09-12 : 14:40:36
Hi there,
I generate dynamic sql in stored procedure and need to have quotation mark there. Resulting (very simplified) query should look like this:

select * from tableA where contains(column1,'"what_I_search*"')'

keyword 'contains' is the function which does fulltext search in column column1,here is the part of the code that generates the query:

SELECT @sql = @sql + ' AND contains(column1,'Here is problem')'

The problem is I don't know how to generate quotation " sign. Any idea how to do this?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-09-12 : 14:52:09
Double up the single quotation marks.

SELECT @sql = @sql + ' AND contains(column1,''Here is problem'')'

Tara
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-09-13 : 05:41:42
Or if its already in a variable, and you need to "double up" the quotes you can use

REPLACE(@sql, '''', '''''')


For example:

SELECT @sql = 'SELECT * FROM MyTable WHERE MyColumn =''FOO'' '
SELECT @sql = 'SELECT * FROM OPENQUERY(MyRemoteServer, REPLACE(@sql, '''', '''''')

Kristen
Go to Top of Page
   

- Advertisement -