Solved

MS SQL Equivalent of specific MySQL Alter table commands

Posted on 2014-12-24
2
184 Views
Last Modified: 2014-12-24
Dear sirs,
What can be the MS SQL equivalent of the following MySQL commands?
Alter table table1 add column middleName varchar(50) after firstName
Alter table table1 add column employeID int first
Actually I am looking at reordering columns in MS SQL programmatically.

I am looking forward to hearing from you.

Omer Pitou
0
Comment
Question by:Omer-Pitou
2 Comments
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 40516579
I'm not aware of any specific command that will do that. MS SQL's ALTER TABLE / ADD COLUMN only adds columns to the end of the table. When you need to reorder columns, you need to create a temporary table with the new column order, then import the data from the existing table to the new table, drop the existing table and then rename the new table. This is how SQL Server Management Studio does it when you choose the Generate Script option after modifying a table's structure.
0
 

Author Comment

by:Omer-Pitou
ID: 40516592
Thank you for your prompt reply. Hope Microsoft will add something like that in the future version.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question