Forum Discussion

AnmolGan81's avatar
AnmolGan81
Advocate II
3 months ago
Solved

Publishing into Target Warehouse using VS Code causing issues

I am trying to publish existing warehouse to another target warehouse using VS Code, when I try to publish it I get below error, some of my tables are using dynamic sql related to INFROMATION_SCHEMA....
  • v-moharafi-msft's avatar
    v-moharafi-msft
    3 months ago

     

    Hi AnmolGan81 ,

     

    Thanks for your Patience.

     

    Yes, post-deployment scripts can be used as part of the SQL Database Project deployment flow in a DevOps pipeline. In this scenario, they are particularly useful because the issue is occurring during design-time validation rather than during runtime execution inside the Fabric Warehouse.

    A practical workaround is to separate the main schema deployment from the stored procedures containing dynamic SQL or unsupported dependency references.

    Edit the .sqlproj file directly and add a <PostDeploy> item inside the <ItemGroup> section:

    <ItemGroup>
        <PostDeploy Include="scripts\after-script.sql" />
    </ItemGroup>
    
    Similarly, pre-deployment scripts can be added using:
    
    <ItemGroup>
        <PreDeploy Include="scripts\before-script.sql" />
    </ItemGroup>

    When the SQL project is built, these scripts are packaged into the generated DACPAC. During deployment through the DevOps pipeline using tools such as SqlPackage or DACPAC deployment tasks, the execution order is handled automatically:

    1.Pre-deployment script
    2. Schema deployment/publish
    3. Post-deployment script

    Since post-deployment scripts execute after schema publish completes, they may help bypass the dependency validation failures occurring during the build/publish phase.

    Hopefully, separating the procedures containing dynamic references from the primary schema deployment helps resolve the deployment validation issue in your scenario

     

    For more information refer to the documentation:

    add-pre-deployment-and-post-deployment-scripts 

    Best Regards,
    Abdul Rafi