?
Solved

MS SQL Equivalent of specific MySQL Alter table commands

Posted on 2014-12-24
2
Medium Priority
?
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 2000 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

752 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