Hi, i'm having problems executing the following
SET @.SQLAH = 'SELECT sub_id WHERE '
SET @.SQLAH = @.SQLAH + 'VENUE_TYPE = Hotel'
EXEC(@.SQLAH)
Its getting stuck at Hotel. I realise that it should include an apostrophe either side like so:
..
SET @.SQLAH = @.SQLAH + 'VENUE_TYPE = 'Hotel' '
..
But this escapes the string, how would i escape an apostrophe in a string?
I thought maybe:
SET @.SQLAH = @.SQLAH + 'VENUE_TYPE = \'Hotel\' '
But no joy :confused:
ThanksAs far as I know MS SQL is using the ANSI standard for that: two single quotes:
SET @.SQLAH = @.SQLAH + 'VENUE_TYPE = 'Hotel'''
(Don't know if it works inside a procedure though)|||hi
nope, it doesnt work - i'm using a stored procedure
:eek:|||SET @.SQLAH = @.SQLAH + 'VENUE_TYPE = ''Hotel'' '-PatP|||thats the badger! cheerssql
Monday, March 26, 2012
escaping an apostrophe in MSSQL
Labels:
apostrophe,
database,
escaping,
executing,
followingset,
microsoft,
mssql,
mysql,
oracle,
select,
server,
sql,
sqlah,
sub_id,
venue_type
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment