-1

My employer has the habit of giving customer specific tables a name, starting with the name of the customer. This makes it difficult to call the sp_rename stored procedure for renaming column names, as you can see:

/*Version 1:*/
sp_rename 'Customer.FinishedProduct.ShortDescr', 'ShortDescription', 'COLUMN';
sp_rename 'Customer.LogTrackAndTrace.StorePreceddure', 'StoredProcedure', 'COLUMN';
/*Version 2:*/
sp_rename '[Customer.FinishedProduct].[ShortDescr]', '[ShortDescription]', 'COLUMN';
sp_rename '[Customer.LogTrackAndTrace].[StorePreceddure]', '[StoredProcedure]', 'COLUMN';

Both versions don't work.

Do you know how this can be written? (The name of a table is 'Customer.FinishedProduct'.)

Dominique
  • 609
  • 1
  • 7
  • 23

1 Answers1

0

If I understand correctly, your table (or schema?) has the dot/period character - . in the name?

The following example shows how you can rename a column when the object names (both schema and object in this case) have that character in them.

CREATE DATABASE Test
GO

USE Test GO

CREATE SCHEMA [a.b] GO

CREATE TABLE [a.b].[c.d] ( e INT )

GO

sp_rename '[a.b].[c.d].[e]', 'New', 'COLUMN';

SELECT * FROM [a.b].[c.d]

enter image description here

SE1986
  • 2,142
  • 4
  • 30
  • 61