Script Method 
Think of the scripting options available in Enterprise Manager. You can reproduce them all in DMO, plus some! In this example I'm creating one script per database containing all of it's views. I'm using the appendtofile flag so that each time I script an object, it doesn't overwrite the previous script. The primaryobject flag is the one that tells DMO to generate the DDL for the object. This example also makes use of the CommandShellImmediate method ?which directly corresponds to xp_cmdshell. Take a look also at the nested loops, the outer one for the databases, the inner for the views ?objects make this kind of looping incredibly easy. Dim oServer      'As SQLDMO.SQLServer Dim oDatabase    'As SQLDMO.Database Dim oView        'As SQLDMO.View 
Set oServer = CreateObject("SQLDmo.SqlServer") 
oServer.LoginSecure = True oServer.Connect "(local)" 
'this deletes previous versions of scripts - use with care! oServer.CommandShellImmediate "Delete C:\DMO_Views*.sql" 
'loop through each view in each database, creating one script per database 'to create all of the views For Each oDatabase In oServer.Databases     For Each oView In oDatabase.Views         'SQLDMOScript_AppendToFile=8192         'SQLDMOScript_ObjectPermissions=2         'SQLDMOScript_ToFileOnly=64         'SQLDMOScript_PrimaryObject=4         oView.Script 8192 + 2 + 64 + 4, "C:\DMO_Views_" & oDatabase.Name & ".sql"     Next Next 
'clean up oServer.DisConnect Set oServer = Nothing 
Msgbox "Done."