Adjust a constraint statement

You must edit the Pre-Snapshot.sql script to adjust DROP CONSTRAINT statements for hyphens in the CatalogName_Language_Catalog tables.

A foreign key constraint will make the Pre-Snapshot.sql script fail due to a dash in the statement that is not "escaped" properly. The statement is hidden inside an IF Exists statement, as follows:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_AdventureWorksCatalog_en-US_Catalog]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[AdventureWorksCatalog_en-US_Catalog] DROP CONSTRAINT FK_AdventureWorksCatalog_en-US_Catalog
GO

To make this run script successfully, add a set of brackets around the variable name at the end of the DROP constraint call, as shown in the following code:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_ AdventureWorksCatalog_en-US_Catalog]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[ AdventureWorksCatalog_en-US_Catalog] DROP CONSTRAINT [FK_AdventureWorksCatalog_en-US_Catalog]
GO

This issue may arise in other constraints if you have multiple languages or catalogs. After you have made these changes, your script is ready to be included in the publication. The next step is to update the publication with the modified script.

Proceed to the next step, Step 4: Updating the Publication with the Modified Script.

Copyright © 2005 Microsoft Corporation.
All rights reserved.