How to make script of a db dynamiclly ?

  • Hi,

    What I want is to make a script of a db dynamically  by a procedure so that another db can be created with all objects on any other server.

    I tried to get objects info from syscomments but in vain in case of tables.

    Any idea will be appreciated ..

    Thanks in Advance.

     Amit Choudhary

     

     

     

     

  • Make use of the script given below.

    http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=486

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

  • would someone mind helping me understand whats going on in this script? For instance:

     

        FOR EACH oLogin IN oServer.Logins

            ''SQLDMOScript_AppendToFile=256

            ''SQLDMOScript_ToFileOnly=64

            ''SQLDMOScript_PrimaryObject=4

     ''SQLDMOScript2_LoginSID=1048576

     ''SQLDMOScript2_EncryptPWD=128

     ''SQLDMOScript2_UnicodeFile=4

            oLogin.Script 256 + 64 + 4, "<path for output files>" & oServer.Name & "_LOGIN.sql",1048576 + 128 + 4

        NEXT

     

     

    what are the numbers for in this script? Where do the variables come from, i mean are they SMO constants or user difined variables ( variables like  ''SQLDMOScript_ToFileOnly)? Are they only flags?

  • Thanks Sugesh For valuable help..

     

    For Winston : The code was in VB and like 'SQLDMOScript_AppendToFile are flag of enum can be used in call script method according to ur requirement. 

    Accutally one should use these   flags only while doing coding not numbers of flag, sicne it would be confusing and bad programming in my sight.

     

    Thanks,

    Amit Choudhary  

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

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