0

Can anyone guide me how to replace single Quote by Double Quote in SQL Server.... I am trying to Search Data (eg: Don't) from SSRS.

It is trowing an error....(Unclosed Quotation mark)

 set  @projectDescription = replace (@projectDescription, '''', '')
 print  @projectDescription....

Can u pls tell int this scenario...

sk7730
  • 636
  • 3
  • 9
  • 32
  • I dont see any function for character replace in SSRS Searching Parameter. From .NET web application i did it by replacing single quote by double quotes. – sk7730 Feb 10 '14 at 05:32

2 Answers2

3

i Think below code will work fine..

    set  @projectDescription = replace (@projectDescription, '''', '''''')
    print  @projectDescription
sk7730
  • 636
  • 3
  • 9
  • 32
0

Just double the single quotes, e.g.

select * from sometable where searchCol like 'don''t';

Using double quotes is not the answer - they are being deprecated, as ANSI uses Double quotes for identifiers, not string literals. More here

Community
  • 1
  • 1
StuartLC
  • 104,537
  • 17
  • 209
  • 285
  • Pls see my Updated Question with scenario...Can u pls guide that scenario? – sk7730 Feb 10 '14 at 05:44
  • I would suggest that you try and parameterise the sql, or better still, create a stored procedure (`select * from sometable where searchcol like '%'+@mySearchPhrase+'%';`) - this way let the driver do all the hard work escaping for you. – StuartLC Feb 10 '14 at 05:55