Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Escape sequence in Transact-SQL-Eurgent 1

Status
Not open for further replies.

raminriahi

Programmer
Sep 9, 2002
31
US
I'm trying to utilize sql statement in an EDI application, but i have problem with handling some special characters:
Single quote '
Double Quote "
Question mark ?

I was wonder if i can use escape sequence notation for them.
(as far as i know ,in java or VB let's say, it's \nnn . is there any similar concept in sql?

* please help ASAP - it's crirical to me !

Thanks in advance,

Ramin
 
If they are within a SQL Server string literal, you can use the CHAR function:
Code:
' ==> CHAR(39)
" ==> CHAR(34)
? ==> CHAR(63)

Example: It's a lovely day ==> 
'It' + CHAR(39) + 's a lovely day'

If your issue is within the SQL command outside of a string literal, you'll need to refer to the language documentation for specific escape characters. Is this a compile error or run-time?

Hope this helps!
--Rob
 
There are escape characters in TSQL, refer to the BOL and look up ESCAPE for more information, but basically it's:


WHERE mycolumn LIKE '5/%' ESCAPE '/'

That makes the % be percent vice a wildcard.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top