Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2005
    Posts
    55

    Unanswered: Completely Script SQL 2005 Database

    Hi Everyone, what im looking for is a way or a freeware utility that will genereate a single SQL Script, for my entire db...

    Just like phpMyAdmin does for MySQL...

    it would need to script my tables, the data of those tables, and all my stored proc's.

    Can SQL Server management studio do this? or does anyone know of a utility that will.

    Thanks, Justin

  2. #2
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    have you tried the Generate Scripts Wizard in SSMS?

    You can get to it off any database node in Object Explorer, under the Tasks flyout menu. Look for "Generate Scripts..."

    I don't think it can script the data though. For that you might take a look at this addin to SSMS:

    http://www.codeproject.com/useritems/enisey.asp

  3. #3
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    If you know a little C# and want to try writing your own, SMO exposes pretty much every object in SQL Server, and each one has a Script() method which returns a StringCollection.

    So it would be a pretty simple matter to write your own app to do this using SMO. I have done it actually. When I get a chance I'll post it on my site - link below. I'll try to get it posted this weekend.

  4. #4
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    Just saw this post, looks like it may be of use to you:

    http://www.dbforums.com/showthread.php?t=1610233

  5. #5
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    Here's the app I was talking about above. It doesn't script all the data, just the objects. It generates a separate file for each object. I did it that way so it's easy to put a db under source control if it's not already.

    http://www.elsasoft.org/tools.htm

    Edit: I couldn't help myself. So I just added some code so that scriptdb.exe that will script out the data as well (optionally) using bcp.exe.
    Last edited by jezemine; 10-22-06 at 00:16.

  6. #6
    Join Date
    Aug 2005
    Posts
    55
    Hi,

    Thank you for that script, it worked a charm,

    how ever i was looking for something that will script it to a .sql file... as in, INSERT INTO type stuff...

    Cheers, Justin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •