This code works in query analyzer to rename one column in a table, can someone please give me the script to rename more than one column in a table and along with that, I need to change the data type (length) while I'm at it.
sp_rename 'medicaid.col001', 'id', 'COLUMN'
I usually rename and modify data types like so:
Change Datatypes:
ALTER TABLE table_name ALTER COLUMN some_column varchar(100);
Change Column Name:
ALTER TABLE table_name RENAME COLUMN old_name to new_name;
I know it's not all in one query to the DB but maybe you could make a procedure to take care of it? Or if you're doing this in an application it shouldn't matter.