The SQL query to rearrange the columns in a table in SQL Server 2005 is as follows:
ALTER TABLE tablename ALTER COLUMN columnname columndatatype AFTER columntomove_after;
In this query, "tablename" refers to the name of your table, "columnname" refers to the name of the column you want to move, "columndatatype" refers to the data type of the column, and "columntomove_after" refers to the name of the column you want to move the first column after.
For example, if you want to move the "dateofbirth" column after the "last_name" column in the "customers" table, you can use the following query:
ALTER TABLE customers ALTER COLUMN dateofbirth datetime AFTER last_name;
Asked: 2023-07-07 19:49:21 +0000
Seen: 9 times
Last updated: Jul 07 '23