yegor256
yegor256

Reputation: 105043

What special characters I should escape in T-SQL strings?

What special characters I should escape in T-SQL (SQL Server) string?

SET @email = ''[email protected]''

Fails.

Upvotes: 2

Views: 2103

Answers (3)

Fosco
Fosco

Reputation: 38506

There should not be two single quotes in that query...

set @email = '[email protected]'

will work just fine...

You'll need to escape single quotes, which is done by putting 2 single quotes. If for example you really wanted '[email protected]' with the quotes in the database, you would replace ' with '' in the data, and still quote it:

set @email = '''[email protected]'''

Upvotes: 1

rsbarro
rsbarro

Reputation: 27339

If you want @email to have the value '[email protected]', try:

SET @email = '''[email protected]'''

Upvotes: 3

Joe Stefanelli
Joe Stefanelli

Reputation: 135729

No need for the second set of single quotes.

SET @email = '[email protected]'

Upvotes: 0

Related Questions