SMO.scripting performance … | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

SMO.scripting performance …

When I want to script all user-stored-procedures of a db, I use this code :
‘Imports mySQLSMO = Microsoft.SqlServer.Management.Smo
‘ Dim oDatabase As New mySQLSMO.Database
‘ oDatabase = globSMOSrv.Databases("Mydb") RaiseEvent ScriptingStatusNotification("StoredProcedures") ‘jus send the event
globSMOSrv.SetDefaultInitFields(GetType(mySQLSMO.Default), New String() {"Schema", "Name", "IsSystemObject"})
For Each oStoredProc As mySQLSMO.StoredProcedure In oDatabase.StoredProcedures
If Not oStoredProc.IsSystemObject Then
RaiseEvent ScriptingObjectNotification(oStoredProc.Schema & "." & oStoredProc.Name) strColl = oStoredProc.Script(SetScriptingOptions(ApplicationScriptObjectType.StoredProcedures))
For Each str As String In strColl
RaiseEvent ScriptingObjectNotification(oStoredProc.Schema & "." & oStoredProc.Name)
End If
Next oStoredProc

This code is so slow because a.o. it also handles _all_ systemobject-storedprocs. [B)] Is there a way so I can avoid handling non-user-objects ?

Resolved !<br /><br />globSMOSrv.SetDefaultInitFields(GetType(mySQLSMO.<b>StoredProcedures</b>), New String() {"Schema", "Name", "IsSystemObject"})<br /><br />Seems lik you have to take good care of specifying the correct object you want to preload info of <img src=’/community/emoticons/emotion-5.gif’ alt=’;)‘ /> ][blush]<br />