Question : MyGeneration questions.

I have been using the MyGeneration's Build inserts from Table template for quite a while and find it extremely handy. I am now trying to expand the template to accomplish some additional tasks. Most I have been able to figure out by looking at other templates and the documentation, but there is one that is giving me trouble. I was wondering if someone could just give me a nudge in the right direction.

The problem is that I dont know how to distinguish SQL functions from SQL procedures in code. I have implemented code to pull the procedures for the selected db, drop each procedure, and recreate it. However, I have noticed that functions get lumped in with stored procedures and I end up with statements like: DROP PROCEDURE  which of course cause SQL Server to choke. Is there a property I can look at to help me distinguish between procedures and functions or a way to pull only the procedures and pull the functions separately?

Also, two other lesser questions:
Is it possible to script SQL Server jobs in MyGeneration?
Is it possible to script SQL Server logins & their associated DB users in MyGeneration?

Answer : MyGeneration questions.

>> how to distinguish SQL functions from SQL procedures in code.<<

So from sys.objects you can distinguish Functions from Stored procedures from the type column. For instance:

To list all functions:
SELECT * FROM sys.objects WHERE type in (N'FN', N'IF', N'TF', N'FS', N'FT')

To list all procedures:
SELECT * FROM sys.objects WHERE type in (N'P', N'PC')

Random Solutions  
 
programming4us programming4us