Solved

MS SQL Equivalent of specific MySQL Alter table commands

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now