T-SQL - How to escape a single quote in SQL Server?



Single quotes are escaped by doubling them up, just as you've shown us in your example. The following SQL illustrates this functionality. I tested it on SQL Server 2008:
DECLARE @my_table TABLE (
    [value] VARCHAR(200)
)

INSERT INTO @my_table VALUES ('hi, my name''s tim.')

SELECT * FROM @my_table

Results

value
==================
hi, my name's tim.
T-SQL - How to escape a single quote in SQL Server? T-SQL - How to escape a single quote in SQL Server? Reviewed by Unknown on 9:56 PM Rating: 5

No comments:

Powered by Blogger.