Posted: 9/10/2010
Hello,
I want to rename a column of a table....how can i do this?
I know the way to do it through SP
EXEC SP_RENAME @objname = 'customers.CompanName', @newname = 'CompanyName', @objtype = 'COLUMN'
But I couldn't find the way to do it through query.
Does anyone know how to do it?
Thanks.
Sumit
SumitArora said: user="Sumit Arora"]EXEC SP_RENAME @objname = 'customers.CompanName', @newname = 'CompanyName', @objtype = 'COLUMN'
user="Sumit Arora"]EXEC SP_RENAME @objname = 'customers.CompanName', @newname = 'CompanyName', @objtype = 'COLUMN'
This is itself a kind of query what type of query you are asking ?
raghav_khunger said: user="Raghav Khunger"]This is itself a kind of query what type of query you are asking ?
user="Raghav Khunger"]This is itself a kind of query what type of query you are asking ?
By query I mean to say Can i do it by using DDL i.e by using Alter .
Like
Alter table TableName
Thanks,
Sumit Arora
Why do you want to do so ?
Posted: 9/16/2010
hi sumit,
check this url to rename column through sp
http://aspdotnet-suresh.blogspot.com/2010/09/how-to-rename-column-or-table-in-sql.html
sureshdasari said: user="Suresh Dasari"]hi sumit, check this url to rename column through sphttp://aspdotnet-suresh.blogspot.com/2010/09/how-to-rename-column-or-table-in-sql.html
user="Suresh Dasari"]
Hi Suresh ,
I don't see any single difference what you have written in your blog and what Sumit asked, he too has written sp_rename
hi ragav i thought that is query only that's why i have given link thanks for notify me
@Sumit, the safest method is using sp_rename procedure
However, you can see whats happening inside sp_rename by running the followin query:
sp_helptext sp_rename
Therefor, you will be able to discover the logic used in this stored procedure.
This is very good procedure that handles all possible problems that might occur while altering your column_name.
Regards,Hajan