dbTalk Databases Forums  

Column naming/spacing

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Column naming/spacing in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Danny
 
Posts: n/a

Default Column naming/spacing - 04-18-2007 , 05:46 PM






Is it possible to have spacing within a column name? Something like
"column name." I can do it from EM but won't let me do it in query
analyzer. Can someone tell me the command to do this in query
analyzer? Thanks!


Reply With Quote
  #2  
Old   
Plamen Ratchev
 
Posts: n/a

Default Re: Column naming/spacing - 04-19-2007 , 12:13 AM






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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.