Solved

MS SQL Equivalent of specific MySQL Alter table commands

Posted on 2014-12-24
2
190 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

685 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