Recently I encountered a slight issue with the Import Scripts function on the Visual Studio 2008 database project.
Situation:
I was receiving the following error when executing one of my stored procedures in SQL Server 2005.
INSERT failed because the following SET options have incorrect settings: 'ANSI_NULLS, QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or query notifications and/or xml data type methods.
Reason:
The stored procedeure has TSQL syntax that required:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Cause:
This was only occuring after I did a Deploy from the database project in visual studio. When I built the SP, and when I re ran my original SP script manually everything worked fine. It seemed that the database project was altering these settings. What I found is that the ScriptsIgnoredOnImport.sql contained the two SET options that my SP required, and when the database project deployed, it obviously didn't use those SET options.
Fix:
This probably sounds really obvious but here it is:
In the database project select your stored procedure in the solution explorer, bring up the properties windw (F4), and set the ANSI nulls property to On and the Quoted Identifiers property to On. (Stop laughing now ok)
A bug? Well I'm sure MS would say this is a Feature, but it seems that the Import Script function ignores the SET options for the stored procedure imports.