April 16, 2012 at 1:55 am
Hello Everyone,
could anyone please help me in finding out a solution on how :
To change the Column name to the old one?
1. Selecting a Column name from a table (using sys tables) and storing it in a Variable.
2. Converting it into All Upper Case
3. Series of Alter Table SQLs are executed where keys are dropped and created etc
4. And at last, I need to revert the changes made to the Column Name i.e to rename it as before.
I need help in the last step. Is there anyway to perform it using sys tables or others ?
Your help is appreciated !
Thanks
Devesh
April 16, 2012 at 5:34 am
April 18, 2012 at 2:54 pm
It's good business to provide the schema name as well to avoid any issues with scope where default schema names can get involved.
Also, do not provide square brackets in the "new name" string otherwise they will become part of the name.
EXEC sys.sp_rename
@objname = N'[SchemaName].[TableName].[OldColumnName]', -- provide schema name
@newname = 'NewColumnName', -- no square brackets unless you want them in the name
@objtype = 'COLUMN';
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply