Skip to content Skip to sidebar Skip to footer

Can Double Quotes Be Used To Delimit A String?

I was surprised to encounter a SQL 2008 T-SQL proc that used a double quote as a string delimiter. For example: DECLARE @SqlStmt AS VarChar(5000) SET @SqlStmt = 'ok' PRINT @SqlStmt

Solution 1:

If QUOTED_IDENTIFIER is OFF then they can be used to delimit a string. Otherwise items in double quotes will be interpreted as object names.

Always use single quotes to delimit strings and square brackets for those object names that require delimiting so your code doesn't break when run under the "wrong" setting.

Solution 2:

Like already Martin Said, you could use like this.

SET QUOTED_IDENTIFIER OFF
BEGINDECLARE@SqlStmtASVarChar(5000)
SET@SqlStmt= "ok"
PRINT @SqlStmtEND

Post a Comment for "Can Double Quotes Be Used To Delimit A String?"