SQL Compare部署脚本不包括所有ALTER SCHEMA命令

时间:2013-10-28 14:57:59

标签: sql-server redgate sqlcompare

我有一个数据库,我正在尝试清理SQL Server 2008(而不是R2)。目前,所有表都驻留在dbo架构中。有些表名是单数,有些是复数。

我创建了一个新架构,crm。我将所有表从dbo移动到crm,并重命名了单个表名以匹配多个表名。当我在开发数据库和生产之间执行SQL Compare(版本10.4.8.87)时,脚本包括以下内容:

PRINT N'Creating schemata' 
GO 
CREATE SCHEMA [crm] 
AUTHORIZATION [dbo] 
GO 

... 

(removes foreign key constraints, notice it removes them from the plural tables in dbo schema) 

PRINT N'Dropping foreign keys from [dbo].[CustomersCommittees]' 
GO 
ALTER TABLE [dbo].[CustomersCommittees] DROP CONSTRAINT [FK_CustCom_ComID] 
ALTER TABLE [dbo].[CustomersCommittees] DROP CONSTRAINT [FK_CustCom_CustID] 
GO 

... 

EXEC sp_rename N'[dbo].[Customer]',N'Customers',N'OBJECT' 
ALTER SCHEMA [crm] TRANSFER [dbo].[Customers] 
EXEC sp_rename N'[dbo].[CustomerAddress]',N'Addresses',N'OBJECT' 
ALTER SCHEMA [crm] TRANSFER [dbo].[Addresses] 
EXEC sp_rename N'[dbo].[Committee]',N'Committees',N'OBJECT' 
ALTER SCHEMA [crm] TRANSFER [dbo].[Committees] 

... 

(adds foreign key contraints back, notice how it adds them to the plural tables in the new crm schema, but never included a statement to ALTER SCHEMA) 

PRINT N'Adding foreign keys to [crm].[CustomersCommittees]' 
GO 
ALTER TABLE [crm].[CustomersCommittees] ADD CONSTRAINT [FK_CustCom_ComID] FOREIGN KEY             ([CommitteeID]) REFERENCES [reference].[Committees] ([CommitteeID]) 
ALTER TABLE [crm].[CustomersCommittees] ADD CONSTRAINT [FK_CustCom_CustID] FOREIGN KEY ([CustomerID]) REFERENCES [crm].[Customers] ([CustomerID]) 
GO 

... 

如上所述,它不包括任何已经复数的表的ALTER SCHEMA ... TRANSFER ...命令,并且不需要执行sp_rename命令。

有没有人见过这个?

1 个答案:

答案 0 :(得分:0)

如果我知道SQL Compare如何处理这些其他表格,也许我可以更准确地回答...换句话说,是否需要进行进一步的修改,是否需要重建表格,还是完全忽略它们?“ p>

对于以您喜欢的方式传输的表,是不是因为您使用模式映射来强制SQL Compare将dbo映射到crm?