Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 To create an integer named column

Author  Topic 

anaconda
Starting Member

1 Post

Posted - 2008-11-23 : 23:57:04
Can anyone tell me the method or syntax to create a table having an integer column name like 1. Is this possible? I have been trying hard to name the column as an integer like 1 or 2 or 3 - 5 but getting failed.

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-11-24 : 00:16:19
you can put any name with the delimited identifiers...

create table abc([1] int, [2] int)
go

Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-24 : 00:28:05
While this can be done. Its not advisable to do this other than for testing purpose. the column names used should as descriptive as possible. At a later point of time, any person who needs to do a mainatianence work on this code will struggle to understand what 1,2,... columns do. SO its always better to make column names meaningful.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2008-11-24 : 01:48:04
>> SO its always better to make column names meaningful.
I just love it when people say things like "always".
It's a good to take a bit of time to think of situations where it might not be the case.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-11-24 : 01:52:12
i thought of this question is for his/her personal interest. i'm sure it is not for any live or development systems.
Dear Anaconda,
never use these type of naming conventions at any cost as Visakh and nr suggested

Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-24 : 01:55:48
quote:
Originally posted by nr

>> SO its always better to make column names meaningful.
I just love it when people say things like "always".
It's a good to take a bit of time to think of situations where it might not be the case.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.


Can you suggest any situation where this will prove to be a better approach?
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2008-11-27 : 00:10:02
Try looking at systems like SAP, CRM, sharepoint, ...
Anything that deals with generic data

I always add a Trace table to systems with columns

entity, key1, key2, key3, data1, data2, data3, spid, dateadded





==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -