Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

I have 4 SQL scripts that I want to run in a DACPAC in PostDeployment, but when I try to build the VS project for 3 of them I get this error:

Only one statement is allowed per batch. A batch separator, such as 'GO', might be required between statements.

The scripts contain only INSERT statements in different tables on the DB. And all of them are structured like so

IF NOT EXISTS (SELECT 1 FROM dbo.Criteria WHERE Name = 'Mileage') INSERT INTO dbo.Criteria(Name) VALUES ('Mileage');

only on different tables and with different data.

My question is why is VS complaining about 3 of them when all the scripts are the same in terms of syntax and operations?

PS: Adding 'GO' between statements as the error suggests doesn't do anything.

1 Answer

0 votes
by (40.7k points)

Even I have faced the same problem. I forgot to set Build Action = None from the file properties when I had added the file in VS. 

Therefore, setting the Build Action= None fixed the problem and now, the project compiles completely fine.

Related questions

0 votes
0 answers
0 votes
1 answer
asked Jul 18, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer

Browse Categories

...