I need help with SQL Server Table Column. I´m trying to rename Column Name, but this doesn't work.
USE COST_mesta_test GO EXEC sp_rename '[dbo].[1965$].obec' , 'people' , 'COLUMN' GO
I tried different combination of brackets [] and path to table "obec" (for example: 1965.obec; 1965$.obec; 1965.[obec]; etc.) But still i get an error:
Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.
You can also change the column name by right-clicking on the Column name and choosing 'rename' option in the Object Explorer.
I don't really understand how your table is set up - ie. the table name, the column name etc - so this is an example of how the proc works for column renames:
If I had a table like this:
CREATE TABLE [dbo].[Company]( [ID] [int], [CompanyName] [varchar](20) )
and wanted to change the [CompanyName]
column, this is the command:
EXEC sys.sp_rename @objname = N'dbo.Company.CompanyName', @newname = 'Name', @objtype = 'COLUMN'
I suspect that your first argument is not correct.
From the documentation (sp_rename (Transact-SQL))
If the object to be renamed is a column in a table, object_name must be in the form table.column or schema.table.column. If the object to be renamed is an index, object_name must be in the form table.index or schema.table.index
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With