Tuesday 7 June 2016

How to replace single quote with double quote

In C#

                strComment = ""Manoj tyagi's photo;
                strComment = strComment.Replace("'", "''");


In Sql :

EX 1


DECLARE @sql varchar(max)
SET @sql = ' INSERT INTO ' + @tempTablea + 
       ' SELECT 0 as TypeA, 0 as TypeB, ' + ''''+
         replace( @name ,'''','''''')+''''+' as Name
       FROM #tempTableb tt2'

Ex 2

UPDATE myTable1
SET myField1 = REPLACE(myField1, '''', '"');

No comments:

Post a Comment