createtable[NewTable]([old_column_1] int
,[new_column_1] varchar(max)-- new col at location,[old_column_2] int
);insertinto[NewTable]([old_column_1],[old_column_2])select[old_column_1],[old_column_2]from[OldTable](nolock);droptable[OldTable];
sp_rename '[NewTable]','[OldTable]';
To my knowledge there is no known method to change the order of the column.But you can achieve this by two ways.
first is:
go into SQL Server management Studio, and "design" an existing table. Insert a column in the middle and look at the script it creates.
nserts all data from old into new, drops the old table and then uses a stored procedure to rename the new table to old.
create table [NewTable] ( [old_column_1] int ,[new_column_1] varchar(max) -- new col at location , [old_column_2] int ); insert into [NewTable] ( [old_column_1], [old_column_2] ) select [old_column_1], [old_column_2] from [OldTable] (nolock); drop table [OldTable]; sp_rename '[NewTable]', '[OldTable]';
Upendra Pratap ShahiPosted Jun 23, 2015, 1:28 AM
Rajeesh MenothPosted Jun 23, 2015, 1:20 AM
Pankaj Kumar ChoudharyPosted Jun 23, 2015, 1:20 AM
shushil kumarPosted Jun 23, 2015, 1:05 AM
Rajeesh MenothPosted Jun 23, 2015, 1:02 AM
shushil kumarPosted Jun 23, 2015, 12:57 AM
shushil kumarPosted Jun 23, 2015, 12:57 AM
Upendra Pratap ShahiPosted Jun 23, 2015, 12:55 AM
Rajeesh MenothPosted Jun 23, 2015, 12:15 AM
Pankaj Kumar ChoudharyPosted Jun 22, 2015, 8:13 PM