Command Line Scripting of Database Objects

  • I know I can use SSMS to script DB Objects. However, is there a command line utility or version? I need something where I can script out certain Views or Tables or SPs or whatever, as needed, as a Change Control process.

    I do database backups prior to implementing changes into Production, but if the changes are few I'd like to simply rebuild the replaced OBJECTS via the scripting I do as a backup.

    thanks in advance

  • rew-370421 (10/28/2010)


    I know I can use SSMS to script DB Objects. However, is there a command line utility or version? I need something where I can script out certain Views or Tables or SPs or whatever, as needed, as a Change Control process.

    I do database backups prior to implementing changes into Production, but if the changes are few I'd like to simply rebuild the replaced OBJECTS via the scripting I do as a backup.

    thanks in advance

    There is, but it's a third party software component. It's a freebie too. Here is the link:

    http://elsasoft.org/tools.htm

  • Thanks for the link, Luk.

    I see it uses SMO, which I know nothing about.

    Are there any SQL2005 out of the box EXE or utilities I can use?

  • For no cost, you can install PowerShell and put that to work, again using SMO. A script to generate all database objects would only be about 30 lines. I have one, but it's due to be published in a book soon, so I can't share it here. It'd be trivial to recreate though.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

  • rew-370421 (10/28/2010)


    Thanks for the link, Luk.

    I see it uses SMO, which I know nothing about.

    Are there any SQL2005 out of the box EXE or utilities I can use?

    I don't think there are. But the software I mentioned comes with source code and it is fairly simple to modify. It will take you about an hour or so to step through it and make appropriate changes if you've coded before.

  • Great. Thanks!

Viewing 6 posts - 1 through 5 (of 5 total)

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