scriptdb - useful for getting db into source control

  • Just a quick note to let you all know about a (free) app I wrote that will script all the objects and (optionally) data in any 2000 or 2005 database.

    It creates a separate file for each object, in a directory tree structure similar to that in Object Explorer in SSMS. It's very useful for getting your database scripts under source control if they are not already.

    I posted the source as well so you can easily modify it to meet your needs if you know a little C#.

    You can get it here:

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

    hope it's useful to some of you!

    ---------------------------------------
    elsasoft.org

  • It seems like a great tool but it never finishes running scripting.  It will output the data and objects of all the tables from any db or server (all different versions of sql server 2000).  But I will get this error message right after it finishes scripting the tables :

     

    Exception caught in Main()

    ---------------------------------------

    Operation not supported on SQL Server 2000.

    Microsoft.SqlServer.Management.Smo.InvalidVersionEnumeratorException

       à Microsoft.SqlServer.Management.Smo.XmlReadDoc.LoadFile(Assembly a, String strFile)

       à Microsoft.SqlServer.Management.Smo.SqlObject.LoadInitData(String file, ServerVersion ver)

       à Microsoft.SqlServer.Management.Smo.ObjectCache.LoadElement(ObjectLoadInfo oli, ServerVersion ver)

       à Microsoft.SqlServer.Management.Smo.ObjectCache.GetElement(ObjectLoadInfo oli, ServerVersion ver)

       à Microsoft.SqlServer.Management.Smo.ObjectCache.GetAllElements(Urn urn, ServerVersion ver)

       à Microsoft.SqlServer.Management.Smo.Environment.GetObjectsFromCache(Urn urn, Object ci)

       à Microsoft.SqlServer.Management.Smo.Environment.GetData(Request req, Object ci)

       à Microsoft.SqlServer.Management.Smo.Enumerator.GetData(Object connectionInfo, Request request)

       à Microsoft.SqlServer.Management.Smo.ExecutionManager.GetEnumeratorDataReader(Request req)

       à Microsoft.SqlServer.Management.Smo.SqlSmoObject.InitChildLevel(Urn levelFilter, ScriptingOptions so, Boolean forScripting)

       à Microsoft.SqlServer.Management.Smo.SmoCollectionBase.InitializeChildCollection(Boolean refresh)

       à Microsoft.SqlServer.Management.Smo.SmoCollectionBase.GetEnumerator()

       à Elsasoft.ScriptDb.DatabaseScripter.ScriptSchemas(Boolean verbose, Database db, ScriptingOptions so, String outputDirectory)

       à Elsasoft.ScriptDb.DatabaseScripter.GenerateScript(String connStr, String outputDirectory, Boolean scriptData, Boolean verbose)

       à Elsasoft.ScriptDb.Program.Main(String[] args)

    ---------------------------------------

    O:\>

  • oops!  I should have tested this on 2000   The problem is the tool is trying to script an object that doesn't exist in 2000 (like assemblies or something).

    I'll fix it and post back here.

    ---------------------------------------
    elsasoft.org

  • That's what I thaught but I don't have VS installed here so I didn't bother to try to fix the code.

     

    Thanx in advance for the fix.

  • ok, this is fixed now. problem was the code was trying to script schemas, and schemas don't exist on 2000. SMO is rather strict about what you ask it to do - if you ask it to enumerate an object type that doesn't exist on the platform you are targeting, it throws an exception.

    Now these objects are scripted only on 2005:

    CLR udts

    schemas

    ddl triggers

    assemblies

    thanks for catching this. I have updated the source and binary on my site.

    ---------------------------------------
    elsasoft.org

  • Thanks mates.

    Regards.

    MS LIVE SUPPORT

    microsoftofficesupport.org[/url]

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

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