Having installed Sql Server Data Tools, I am attempting to use SqlPackage.exe
from: C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin\
I'd like to "extract" schema and data. This is so I can migrate to a new Server that does not have any existing database - I want the schema and data to be included in that migration. This is just a spin up / throwaway environment.
The existing databases aren't great in that they have cross database references. The database I want to export has multiple references to another database named "audit". Triggers are involved - hopefully you get the picture.
Having read the docs, I tried this command:
.\sqlpackage.exe /Action:Export /SourceDatabaseName:"MyDb" /SourceServerName:foo\bar /TargetFile:"C:\temp\mydb.bacpac"
However this resulted in many of the following errors:
Error SQL71562: Error validating element [dbo].[foo_u]: Trigge
r: [dbo].[foo_u] has an unresolved reference to object [Audit].[dbo].[Foo].[FooId]. External references are not supported when creating a package from this platform.
I tried specifying /p:VerifyExtraction=false
but this resulted in:
.\sqlpackage : *** 'VerifyExtraction' is not a valid argument for the 'Export' action.
So now I am thinking wow this must just not be supported. However in VS2017, when I went to SQL server explorer, I can "Extract data tier application" and choose options for "Extract schema and data" for all tables. This runs fine and produces a "foo.dacpac" file - the UI provides an option for "verify extraction" which I leave unchecked.
Now I am doubly confused because I thought dacpac files contain schema only, and bacpac
files were for schema plus data - yet when extracting a data tier application "with data" via visual studio it produces a dacpac file. Does this mean I need to be using the "Extract" action rather than the "Export" action of SqlPackage.exe?
Can anyone offer any guidance on this?