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)
 How to concatenate a single quote?

Author  Topic 

Chen
Starting Member

4 Posts

Posted - 2005-07-18 : 23:47:31
Hi all,

I am new to SQL server. I am trying to concatenate a single quote for a variable.
Here is my unworking code.

SET @sqlStmt = 'UPDATE ' + @targetTbl + ' SET ' + @targetCol + ' = '+ ''' + @newValue + ''';

I want @sqlStmt to be

UPDATE mytable SET mycolumn = 'myname'

Any help will be appreciated!

Chen

nosepicker
Constraint Violating Yak Guru

366 Posts

Posted - 2005-07-19 : 00:38:22
You were close:

SET @sqlStmt = 'UPDATE ' + @targetTbl + ' SET ' + @targetCol + ' = ''' + @newValue + '''';
Go to Top of Page

Chen
Starting Member

4 Posts

Posted - 2005-07-19 : 07:04:04
Thank you so much, nosepicker!
You are the man!
Go to Top of Page
   

- Advertisement -