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
...
前述のように、既に複数形であり、sp_rename コマンドを実行する必要がないテーブルの ALTER SCHEMA ... TRANSFER ... コマンドは含まれていません。
他の誰かがこれを見たことがありますか?