I am programming an application in C # to extract the stored procedures from a database and generate the corresponding scripts. The problem I get is that when I get the StoreProcedure objects, it brings me the SystemStoreProcedures as well, I have been searching for information but I have not found any code to filter it, I thought of doing the following:
1) I get the procedures of a database:
StoredProcedureCollection spcoll = srv.Databases["demo"].StoredProcedures;
2) Then I go through the list with a foreach to filter the store procedures that are system and leave them in a new list where I will finally get the stored procedures that I want to get out.
List<StoredProcedure> lista = new List<StoredProcedure>();
foreach (StoredProcedure item in spcoll)
{
if (item.IsSystemObject == false)
{
lista.Add(item);
}
}
This works correctly, I add the StoreProcedure that corresponds to the database and that are not system to the list, the problem in doing this takes too much between 10-20 seconds, my query is if there is a more efficient way to do this.
Greetings.