想看看我是否可以获得有关在 MSSQL Server 2008 中更改和重命名表的帮助。我收到有关 sp_name 语法的错误消息,也许我做错了什么?
-- Archives data existing one week ago and then recreates production table (registration data)
IF EXISTS (SELECT * FROM dbo.tab_reg13_old) DROP TABLE dbo.tab_reg13_old;
sp_rename 'dbo.tab_reg13', 'dbo.tab_reg13_old';
CREATE TABLE [dbo].[tab_reg13](
[badge] [nvarchar](255) NULL,
[firstname] [nvarchar](255) NULL,
[lastname] [nvarchar](255) NULL,
[degree] [nvarchar](255) NULL,
[title] [nvarchar](255) NULL,
[company] [nvarchar](255) NULL,
[address1] [nvarchar](255) NULL,
[address2] [nvarchar](255) NULL,
[city] [nvarchar](255) NULL,
[state] [nvarchar](255) NULL,
[zipcode] [nvarchar](255) NULL,
[country] [nvarchar](255) NULL,
[email] [nvarchar](255) NULL,
[association] [nvarchar](255) NULL,
[regclass] [nvarchar](255) NULL,
[regtimestamp] [datetime] NULL
) ON [PRIMARY];
收到此错误消息:
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'sp_rename'.