I am scripting all the Stored Procedures in a Database, via SMO. It is now returning Stored Procedures from both DBO and SYS owner/schema's
How do I filter it to only show SP's from DBO please:
StringCollection spScripts = AdventureWorks.Script(scriptOptions);
foreach (StoredProcedure mySP in AdventureWorks.StoredProcedures)
{
foreach (string script in spScripts)
sw.WriteLine(script);
/* Generating CREATE TABLE command */
spScripts = mySP.Script();
foreach (string script in spScripts)
sw.WriteLine(script);
}
The StoredProcedure class has a Schema property, you could use this to filter.
Not sure right now, if StoredProcedures collection implements the right interfaces, but maybe you can even filter it directly on the StoredProcedures object via LINQ