Script to import BACPAC file?

  • Did some searching, and the closest I've seen is using the SqlPackage command-line tool, either directly from CMD or through a PowerShell script.

    I'm aware that in SSMS, you can do this by right-clicking and selecting "Import Data-tier Application". Is there any way to do this through a standard SQL script? Or is the only option to use xp_cmdshell to invoke SqlPackage?

  • Through SQL? No. It's a command line driven process. Powershell is how I would do it. Check out DBATools.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant Fritchey wrote:

    Through SQL? No. It's a command line driven process. Powershell is how I would do it. Check out DBATools.

    As a bit of a sidebar, it's a real shame that so many folks shy away from the proper and safe use of xp_CmdShell.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden wrote:

    Grant Fritchey wrote:

    Through SQL? No. It's a command line driven process. Powershell is how I would do it. Check out DBATools.

    As a bit of a sidebar, it's a real shame that so many folks shy away from the proper and safe use of xp_CmdShell.

    Oh don't get me wrong - I'm not opposed to xp_cmdshell. Just wanted to see if there was anything more "out-of-the-box" that I wasn't aware of.

    I suppose, internally, this is probably due to the fact that the exporting of the data-tier application is driven by a powershell script to begin with.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply