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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to add a new column between two columns

Author  Topic 

senthil.dhaktchana
Starting Member

3 Posts

Posted - 2008-07-25 : 08:19:22
hi,
i have a table with two columns namely empid,empname ..now i need to add the new column between empid and empname columns..if i try to add the column by using alter table command , it will be added next to the empname..but i need to add between two columns ..how can i do it?
regards
senthil

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-25 : 08:21:05
why does it has to be added in between ? the order of column is not important


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-25 : 08:27:27
You will need to export data to table with different name and change your column as you like with data imported back again.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-25 : 08:38:25
Ordinal position of the column doesnt matter as long as you have it in the proper place at the SELECT statement

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

VGuyz
Posting Yak Master

121 Posts

Posted - 2008-07-25 : 09:08:53
I think this column alignment will not become a issue.
If u want to show the column of u'r table
like below
empid,new_column,empname
means

do it with the query like

select empid,new_column,empname from table_name
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-25 : 09:15:16
quote:
Originally posted by VGuyz

I think this column alignment will not become a issue.
If u want to show the column of u'r table
like below
empid,new_column,empname
means

do it with the query like

select empid,new_column,empname from table_name


Exactly what I have described

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-25 : 10:37:09
quote:
Originally posted by madhivanan

Ordinal position of the column doesnt matter as long as you have it in the proper place at the SELECT statement

Madhivanan

Failing to plan is Planning to fail


How many times have we told this before
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2008-07-25 : 10:43:16
but just to make it look pretty you can do it from the SQL Server Management Console. Right click on table name and then click Design. Drag and place your column where ever you want.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-25 : 14:15:02
quote:
Originally posted by rohitkumar

but just to make it look pretty you can do it from the SQL Server Management Console. Right click on table name and then click Design. Drag and place your column where ever you want.



What?????? Try it and reply.You can't change from design unless you don't have any data .
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-25 : 14:16:29
quote:
Originally posted by visakh16

quote:
Originally posted by madhivanan

Ordinal position of the column doesnt matter as long as you have it in the proper place at the SELECT statement

Madhivanan

Failing to plan is Planning to fail


How many times have we told this before



I don't like to say but there are so many twit like this in SQL 2005 administration as well.
Go to Top of Page
   

- Advertisement -