|
Posted by Erland Sommarskog on 10/01/46 11:42
Stu (stuart.ainsworth@gmail.com) writes:
> Obviously, I don''t work with brackets in my table names; just curious,
> why the double "]" at the end? I just tried it, and it blew up. I'd
> like to know so that when I encounter it in the future, I'll understand
> what's going on.
Because in T-SQL whenever you need to include the closing delimiter in
whatever you are delimiting, you need double it:
PRINT 'It''s one o''clock, and time for lunch'
SELECT * FROM [My[]]brackets]
SELECT "Double""quote" = '"'
There is a built in function that can help you with this: quotename().
SELECT quotename('MTIC_PROD_VEND[ 1]')
SELECT quotename(@myinput, '''')
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|