March 2, 2006 at 2:38 am
i have a value in DB abc'def
How do i query for this value ? i am afraid that there is a special char inside.
Select * from MyTable
where col1 ='abc'def'
This wont work
how do i do it ?
March 2, 2006 at 2:50 am
Hi try where col1 = 'abc''def'
Two single quotes, the first quote 'escapes' the the second quote effectively saying the quote is part of the string and not the termination of the string.
March 2, 2006 at 3:47 am
if your parameter is not fixed i.e. if value which you are comparing may contain Single Quotation mark or may not.. in that case before comparing first check for Single Quotation mark and replace it will two single quotation mark
If you are using VB front end you can use replace command
syntax: Replace(string,"'","''")
you can find similar command in other front ends
March 2, 2006 at 4:14 am
Try this:
where col1 like 'abc'def'
or
where col1 like '%abc'def%'
Jagan
March 2, 2006 at 4:28 am
That will just give you syntax errors - double up the single quote.
March 2, 2006 at 6:37 am
WHERE @col1 LIKE 'abc_def'
Far away is close at hand in the images of elsewhere.
Anon.
March 2, 2006 at 10:56 am
Please, take a look at the examples at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_la-lz_115x.asp
LIKE article in Transact-SQL Reference
Better read all article, but if you don't have time then scroll to the middle of the article to the topic:
Pattern Matching with the ESCAPE Clause
Regards,Yelena Varsha
March 3, 2006 at 7:09 am
Where col1 like '%''%'
If its a name that'll get your O'Doyles and O'Connors
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply