sqlpackage publish action creates alter for the whole DB

arielman2304 676 Reputation points
2021-06-15T11:37:42.843+00:00

Hi
I'm running the below sqlpackage action command (my change is only one predeploy script with one alter):

sqlpackage /action:Script /SourceFile:"Database Services\bin\Debug\Database Services.dacpac" /TargetConnectionString:"Data Source=TESTL05,123;Integrated Security=True;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False;Initial catalog=test" /OutputPath:"C:\git\SnapshotDiff.sql  

and when I'm looking in the sql I see this code:

IF EXISTS (SELECT 1
FROM [master].[dbo].[sysdatabases]
WHERE [name] = N'$(DatabaseName)')
BEGIN
ALTER DATABASE [$(DatabaseName)]
SET ANSI_NULL_DEFAULT ON
WITH ROLLBACK IMMEDIATE;
END

why this part was generated? can I avoid it using of one of these flags:
https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-script?view=sql-server-ver15#properties-specific-to-the-script-action

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,631 questions
0 comments No comments
{count} votes

Accepted answer
  1. arielman2304 676 Reputation points
    2021-06-15T12:05:09.077+00:00

    I've found the relevant flag:
    /p:ScriptDatabaseOptions=False

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.