Deployment scripts do not include all ALTER SCHEMA commands

Forum for users of SQL Compare schema synchronization utility

Deployment scripts do not include all ALTER SCHEMA commands

Postby bryangm » Mon Oct 28, 2013 2:56 pm

I have a database that I am trying to clean up on SQL Server 2008 (not R2). Currently, all tables reside in the dbo schema. Some table names are singular, others are plural.

I created a new schema, crm. I moved all of the tables from dbo to crm and I renamed the singular table names to match the plural table names. When I perform the SQL Compare (version between my development database and production, the script includes the following:

PRINT N'Creating schemata'


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

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


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]'
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])


As mentioned above, it does not include any of the ALTER SCHEMA ... TRANSFER ... commands for the tables that were already plural and do not need the sp_rename command to be executed.

Has anyone else seen this?
Posts: 1
Joined: Mon Oct 28, 2013 2:38 pm

Postby Brian Donahue » Thu Oct 31, 2013 10:54 am

We will probably need backups or SQL Compare snapshots to work this out, as well as your project settings (maybe this is a results of manually mapping schemas). We need to know what is different about the tables that are being handled differently. You can reply via email to the support ticket we opened for you.
Brian Donahue
Posts: 6590
Joined: Mon Aug 23, 2004 10:48 am

Return to SQL Compare Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests