How to extract MSSQLServer database as .dacpac without VerifyExtraction?
Solution 1
I wasn't able to find a method that works in SSMS (2008 R2 or 2012), either, but Visual Studio (2013) with SSDT seems to work: Within VS, go to SQL Server Object Explorer, connect to the server in question, right click the database in question, Extract Data-tier Application, and then adjust the Extract Settings, one of which is "Verify extraction". I don't know why MS doesn't just build that into SSMS.
One somewhat-odd thing I noticed from doing, this, though, is that VS will only extract a .DacPac via this method. Even when you choose to add data to the extract, the extension is still .DacPac. I was under the impression that .DacPacs were solely for Schema Only, while .BacPacs were for Schema + Data. Regardless, after VS created the .DacPac (Schema + Data) file, SSMS was able to import it fine using "Deploy Data-tier Application..." wizard.
Solution 2
If you cannot use Visual Studio you can use the command line SqlPackage
application to extract the schema from the database. By default, this does not verify the schema (no, I don't know why SSMS and the command line offering have different defaults!). SqlPackage.exe
can be found in C:\Program Files (x86)\Microsoft SQL Server\<SQL_VERSION>\DAC\bin
.
For example, the following extracts the schema for MyDatabase
from the local SQL Server instance and outputs it to a .dacpac
file on the local filesystem:
sqlpackage /Action:Extract /SourceDatabaseName:"MyDatabase" /SourceServerName:localhost /TargetFile:"C:\SomeDirectory\MyDatabase.dacpac"
If you want to include schema verification at a later stage, you can set the flag explicitly by adding /p:VerifyExtraction=True
to the command line.
Full information on SqlPackage.exe
can be found here:
https://msdn.microsoft.com/library/hh550080.aspx
![Michi-2142](https://i.stack.imgur.com/fY25w.png?s=256&g=1)
Michi-2142
Living my passion and dream to be a software consultant / developer. I'am CEO of the very young company codeunity. We provide an excellent small team to bring your Software (APP or/and Backend) to a next level.
Updated on April 18, 2020Comments
-
Michi-2142 about 4 years
I want to extract a database schema of a MSSQLServer database with Server Management Studio. I use the Extract command "Extract Data-tier Application.."
In the database are several references to another database. Because of this I get the following error.
Error extracting database: Validation of the schema model for data package failed. Error SQL71562: Error validating element [dbo].[x] has an unresolved reference to object [dbo].[y]. External references are not supported when creating a package from this platform.
The problem is, that SSMS uses the SQLPackage.exe with parameter /p:VerifyExtraction=True. When I use the console and call SQLPackage.exe without this Parameter, it uses /p:VerifyExtraction=False by default and I can create the .dacpac file.
Is there a way to configure SSMS to disable verification?
-
Nick.McDermaid about 7 yearsAfter chasing my tail for hours with non functioning powershell scripts, inconsistent assemblies and versions (and I admit lack of experience with Powershell), this worked immediately.
-
Balmus about 7 years@Nick.McDermaid Thanks for the comment, I'm really glad to hear it helped.
-
yvesva over 6 yearsAppears location for SSMS 17.5 is
C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe
-
Balmus over 6 years@yvesva Thanks! Yes, different versions of SQL Server and its tools are stored under separate numbered directories, with
140
corresponding to SQL Server 2017. Instead of hard-coding one of these in my answer, I've now just put<SQL_VERSION>
instead. -
CB_Ron almost 5 years@DaveR. suppose I am trying to extract from Azure SQL Managed Instance. Can I do that with PowerShell also?
-
Balmus almost 5 years@CB_Ron According to the sqlpackage release notes, support for MI was added last year: docs.microsoft.com/en-gb/sql/tools/… Both PowerShell and the command line should behave the same.
-
CB_Ron almost 5 years@DaveR. Sadly, when using sqlpackage with the
/Action:Export
switch, Verify is not a valid property. So I still cannot export both the schema and data. -
Balmus almost 5 yearsHi @CB_Ron. Are you sure you're using
VerifyExtraction
and not justVerify
as the property value?Also, the original question was for schema-only dacpac extraction, I'm afraid. It may be better to author a new question for your particular requirements if you're still having no luck. Sorry my answer didn't help. -
CB_Ron almost 5 years@DaveR. Yes I did use that parameter. It is not valid for
/Action:Export
, verified by the links in your post. I have asked a new question over on dba StackExchange. I'm in the process of testing one of those answers right now. -
Balmus almost 5 years@CB_Ron Use the
Extract
action, notExport
. You're correct that export doesn't support verification; sorry I didn't spot that when answering you previously.