Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
T-SQL
»
add column between two column
add column between two column
Rate Topic
Display Mode
Topic Options
Author
Message
bang.prashant
bang.prashant
Posted Thursday, October 09, 2008 9:57 AM
Valued Member
Group: General Forum Members
Last Login: Friday, October 10, 2008 5:34 PM
Points: 54,
Visits: 221
I have a table having column1,column2,column3,column4
Now I have to modify the table and add two new column column A, ColumnB in between Column1 & Column2.
So new columns list will be column1,column A, ColumnB, column2,column3,column4
How to achieve this using T-SQL?
Post #583437
Adi Cohn-120898
Adi Cohn-120898
Posted Thursday, October 09, 2008 10:04 AM
SSCrazy
Group: General Forum Members
Last Login: Yesterday @ 9:50 AM
Points: 2,019,
Visits: 4,923
bang.prashant (10/9/2008)
I have a table having column1,column2,column3,column4
Now I have to modify the table and add two new column column A, ColumnB in between Column1 & Column2.
So new columns list will be column1,column A, ColumnB, column2,column3,column4
How to achieve this using T-SQL?
You can’t do it. If it is really important for you, you can drop the table and recreate it, but it shouldn’t be important at all. The logical order of the columns is not necessarily the same as the physical order of columns and since you should specify the columns that you want to select clause and not use *, the logical order of columns has no importance at all.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #583445
kschwid
kschwid
Posted Thursday, October 09, 2008 10:05 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Yesterday @ 11:39 AM
Points: 153,
Visits: 235
Not sure if this will help you here is a link to some information.
http://blog.sqlauthority.com/2008/04/08/sql-server-change-order-of-column-in-database-tables/
Respectfully,
K8
Software Developer/Data Analyst
Ozaukee, WI
Post #583447
Jeff Moden
Jeff Moden
Posted Thursday, October 09, 2008 8:15 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Yesterday @ 2:32 PM
Points: 32,906,
Visits: 26,792
Sure you can do it. And, you don't have to write a lick of T-SQL to do it... Enterprise Manager will write all of the code for you.
Open Enterprise Manager and go into design the table. Make the changes that you want including the inserted columns and then click on the 3rd menu icon from the left (Save Change Script). Follow your nose after that.
Now,
SHOULD
you do it? That's a whole 'nuther story... ;)
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #583692
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.