Microsoft KB Archive/928963

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Knowledge Base


Error message when you try to import a Transact-SQL script in Visual Studio 2005 Team Edition for Database Professionals: "The .sql file contains more than one data definition language (DDL) statement."

Article ID: 928963

Article Last Modified on 12/13/2006



APPLIES TO

  • Microsoft Visual Studio 2005 Team Edition for Database Professionals



SYMPTOMS

When you try to import a Transact-SQL script to a database project in Microsoft Visual Studio 2005 Team Edition for Database Professionals, you may receive an error message that resembles the following:

The .sql file contains more than one data definition language (DDL) statement. Remove any additional statements, and retry the operation.

This problem occurs if the following conditions are true:

  • The script contains multiple constraint statements.
  • The script contains a Data Definition Language (DDL) statement such as the following:

    ALTER TABLE [dbo].[titleauthor] ADD
    CONSTRAINT [FK__titleauth__au_id] FOREIGN KEY ([au_id]) REFERENCES [dbo].[authors] ([au_id]),
    CONSTRAINT [FK__titleauth__title] FOREIGN KEY ([title_id]) REFERENCES [dbo].[titles] ([title_id])

    Note The DDL statement is valid. The statement runs successfully in SQL Server Management Studio.


CAUSE

This problem occurs because Visual Studio 2005 Team Edition for Database Professionals does not parse the DDL statement correctly.

WORKAROUND

To work around this problem, manually split the script into multiple statements in the script file. For example, split the script as follows:

ALTER TABLE [dbo].[titleauthor] ADD
CONSTRAINT [FK__titleauth__au_id] FOREIGN KEY ([au_id]) REFERENCES [dbo].[authors] ([au_id])
ALTER TABLE [dbo].[titleauthor] ADD
CONSTRAINT [FK__titleauth__au_id] FOREIGN KEY ([au_id]) REFERENCES [dbo].[authors] ([au_id])

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.


Additional query words: TSQL T-SQL

Keywords: kbtshoot kbprb KB928963