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
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
Add a column to the end of the table:
ALTER TABLE myTable ADD myNewColumn VARCHAR(255);
Add a column to the start of the table:
ALTER TABLE myTable ADD myNewColumn VARCHAR(255) FIRST;
Add a column after an existing column:
ALTER TABLE myTable ADD myNewColumn VARCHAR(255) AFTER myOtherColumn;
For additional options, see MySQL's ALTER TABLE documentation.
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;