Hi,
I need to have an varchar value with single quotes. For eg: the below code throws compilation error.
Declare @.val VARCHAR(20)
SELECT @.val = ''+name+''
print @.val
Error: Invalid column 'name'
I want to print name enclosed with single quotes. Please guide me.
Regards,
SamDeclare @.val VARCHAR(20)
SELECT @.val = 'Kaiowas'
PRINT @.VAL
EDIT (added): SET @.VAL = @.VAL + '''Kaiowas'''
EDIT (added): PRINT @.VAL
SET @.VAL = @.VAL + '''' + @.VAL + ''''
PRINT @.VAL
Showing posts with label quotes. Show all posts
Showing posts with label quotes. Show all posts
Monday, March 26, 2012
Thursday, March 22, 2012
escape single qoute
Is there a way to escape single quotes ' in a sql statement that uses a sql data source that is automated? I know you can do it with a string manip and replacing them with double single quotes. I am just looking for a simple way.
Thanks
Adam
If you are using parameters, you don't have to worry about single quotes in strings because SQL Server preserves the input data as it is.
If you aren't using parameters, you'll have to use two single quotes.
||| You need to use two single quotes.
Subscribe to:
Posts (Atom)