Tuesday, 8 January 2013

Rename Column and Data Type

USE DBNAME


GO
/* The below script change the column name of the SQL Server Table*/

EXEC sp_rename 'dbo.TABLENAME.EXISTING_COLUMN_NAME', 'NEW_COLUMN_NAME', 'COLUMN';

GO

/* The below script change the column data type of the SQL Server Table*/
ALTER TABLE dbo.TABLENAME
ALTER COLUMN NEW_COLUMN_NAME varchar(20) null;

/*To see the changes of the above */

Execute Sp_help  'dbo.TABLENAME'


No comments:

Post a Comment