Import sql objects definiton into individual file

  • Hi,

    I'm trying to put the initial object definition into Azure Devops. My sql servers are on prem 2016. How can I script all the objects definition( table, views, stored procs, function) with if exists drop on the top in to their own individual file so that I can push them to Azure devops. This is for initial import for source control purpose. Going through SSMS and generate scripts for all the objects is time consuming. Any insight on this will be greatly appreciated.

  • You could create a database project in VS and then import the database structure into that. Doing so will create the individual files you need (though not with IF EXISTS ... DROP, because that is not needed).

    https://learn.microsoft.com/en-us/sql/ssdt/how-to-create-a-new-database-project?view=sql-server-ver16

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • SSMS - Right click db - tasks - generate scripts.

    Follow the wizard, ensure you set the right scripting options you need etc.

     

    But yeah if in devops, should be a DB project as Phil said and all done via visual studio

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

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