[sql] Adding a column after another column within SQL

How do I add a column after another column within MS SQL by using SQL query?

TempTable ID int, Type nvarchar(20), Active bit

NewTable ID int, Type nvarchar(20), Description text, Active bit

That is what I want, how do I do that

This question is related to sql

The answer is


In a Firebird database the AFTER myOtherColumn does not work but you can try re-positioning the column using:

ALTER TABLE name ALTER column POSITION new_position

I guess it may work in other cases as well.


It depends on what database you are using. In MySQL, you would use the "ALTER TABLE" syntax. I don't remember exactly how, but it would go something like this if you wanted to add a column called 'newcol' that was a 200 character varchar:

ALTER TABLE example ADD newCol VARCHAR(200) AFTER otherCol;