Unix Technical Forum

Column naming/spacing

This is a discussion on Column naming/spacing within the SQL Server forums, part of the Microsoft SQL Server category; --> Is it possible to have spacing within a column name? Something like "column name." I can do it from ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 02:54 PM
Danny
 
Posts: n/a
Default Column naming/spacing

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!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 02:54 PM
Plamen Ratchev
 
Posts: n/a
Default Re: Column naming/spacing

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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:40 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com