воскресенье, 17 марта 2013 г.

Как заключить строку в квадратные скобки или другой разделитель



DECLARE @STR VARCHAR(50) = ' 1234567 '
SELECT  QUOTENAME(@STR) AS QUOTENAME

GO
DECLARE  @STR CHAR(50) = ' 1234567 '
SET QUOTED_IDENTIFIER ON
SELECT  QUOTENAME(@STR) AS QUOTENAME

SET QUOTED_IDENTIFIER OFF
SELECT  QUOTENAME(@STR) AS QUOTENAME
GO
SET QUOTED_IDENTIFIER ON
DECLARE  @STR CHAR(50) = ' 1234567 '
SELECT  QUOTENAME(@STR) AS QUOTENAME
SELECT  QUOTENAME(@STR,'"') AS QUOTENAME
SELECT  QUOTENAME(@STR,'''') AS QUOTENAME
SELECT  QUOTENAME(@STR,'<>') AS QUOTENAME
SELECT  QUOTENAME(@STR,'<123456789>') AS QUOTENAME