SQL Server Central Webinar Series #5: Setup Your Source Control With Help from PowerShell

  • Comments posted to this topic are about the item SQL Server Central Webinar Series #5: Setup Your Source Control With Help from PowerShell

  • Keep in mind Red Gate has a wonderful tool, Sql Compare and if you have the professional edition it comes with a command-line utility, sqlcompare.exe (I'm not sure why you use SQL Source Control without it!).

    Anyways here's one-liner to script out all of your database objects (one file per object) with a folder structure of Tables, Stored Procedures, Views--i.e. the kind of structure you'd expect to check into source control:

    sqlcompare.exe /s1 "MyServer" /db1 "MyDb" /mkscr:"C:\Scripts"

    I'm a big PowerShell fan, but sometimes it just makes sense to purchase/use an existing tool. You can always wrap PowerShell scripts around the tool as needed.

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

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