HELP: DMO, Scripting Stored procedure, which SQLDMO.SQLDMO_SCRIPT_TYPE constant will force "use"

  • Hi there

    I'm writing a small vb app to manage automatic scripting of selected stored procedures. I'm explicitly setting various script_type settings and that's all great. However I cannot determine which of the sqldmo_script_type constants will force a "use database" statement for each stored procedure like it can be set in Mgmt Studio,Tools,Tools,Scripting. Anybody know the answer to this??

    As a second goal can anyone point to an exhaustive list/description of the meaning of each of the script_type parameters.

    Thanks a million for any help

    Barry

  • Unlikely as it sounds, based on http://msdn.microsoft.com/en-us/library/ms136330.aspx (which appears to have be a complete list of ScriptType values - plus a link to Script2Type at the bottom of the page) it doesn't appear that it's possible to have the "USE database" statement generated by DMO.

    It is possible to do it with SMO (the replacement for DMO in SQL 2005); depending on how far you have got with your app you may not want to switch.

    The database name must already be available as a property from the objects you're constructing to use DMO; perhaps another solution would be to return the DMO text to a string variable, concatenate a "USE database" statement and then write it out to a file from VB, rather than using the DMO method to write out the file for you.

  • Hi there

    Thanks for that

    Yes indeed - I gave up on getting dmo to do itand wrote a little function to insert the use statement into the scriptfile, save it and and then append the script to it.

    Better get started with SMO I suppose

    Thanks for the reply.

    Barry

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

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