Exclude a post deployment script in Visual studio 2013 SQL Server project. I am not explaining the whole requirement why I have to do this. I am explaining part of my issue; please bear it.
I have the following script:
CREATE SCHEMA [College]
CREATE TABLE [College].[Department]
(
[Name] varchar(50) NOT NULL,
)
In a post deployment script I have a script file which is not included in the build, and I am inserting a value in the department table:
INSERT INTO [College].[Department]
([DeptId], [DeptName])
Values('77ACE81C-7C41-4A31-8F39-9814E36548A1', 'Computer')
As my department table doesn't have Department Id, I want to exclude this script, so based on a condition I am including this file by taking the help of a command-line variable. My post deployment file has the following entry:
IF('$(UseDepartMent)' = 1)
BEGIN
PRINT N'Command Line UseDepartment is 1'
:r .\Script.DepartMentTableEntry.sql
END
GO
(90,1): SQL72014: .NET SqlClient Data Provider: Msg 207, Level 16, State 1, Line 47 Invalid column name 'DeptId'.