June 26, 2006 at 12:33 pm
I am trying to fetch data from a table which has apostophe in a one of its char datatype col. It errors out when its fetches for this specific row. is there any easy way of retrieving the data. ANy help will be greatly appreciated
TIA
June 26, 2006 at 12:39 pm
Also to add more onto my previous post lets say i have a col name which has data as xxx'x. now my sql is
select * from tab a
where name = "xxx'x" heres where i am going wrong. how do i get the row which has data with name as "xxx'x". any solns greatly appreciated. THANKS
June 26, 2006 at 1:45 pm
The apostrophe is the escape character for the apostrophy
select *
From tab a
where a.name = 'xxx''x'
June 27, 2006 at 1:20 am
Since you are probably talking about variables here:
DECLARE @TextString varchar(30), @QuoteString varchar(30)
SELECT @TextString = 'Text String'
, @QuoteString = 'Andy'+CHAR(39)+'s Quote String'
SELECT QUOTENAME(@TextString,CHAR(39)) AS TextString
, QUOTENAME(@QuoteString,CHAR(39)) AS QuoteString
You can see that QUOTENAME will not affect a string without the embedded 'quote_character' parameter's value
Andy
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply