You are here: Re: Column naming/spacing « MsSQL Server « IT news, forums, messages
Re: Column naming/spacing

Posted by Plamen Ratchev on 04/19/07 05:13

There are two ways to handle special characters (or reserved keywords) in
identifiers (databases, tables, other object names, etc.):


- using brackets [], like this (the example below includes some other
objects like database and table names with special characters):

SELECT [My Column] FROM [My~Database].[My^User^ID].[My$Table]


- using double quotation marks (this is the SQL-92 syntax), like this:

SELECT "My Column" FROM "My~Database"."My^User^ID"."My$Table"

In order to use the double quotation marks the QUOTED_IDENTIFIER option has
to be ON. You can do that in Query Analyzer by running:

SET QUOTED_IDENTIFIER ON


It is not a good practice to use special characters in identifiers as it
makes code difficult to read and maintain.

HTH,

Plamen Ratchev
http://www.SQLStudio.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация