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
Solved

MS SQL Equivalent of specific MySQL Alter table commands

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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 extract information from SQL Server on Database, Connection and Server properties

829 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