Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you spot a user created SP in MSSQL?

Status
Not open for further replies.

Neil Toulouse

Programmer
Mar 18, 2002
882
GB
Hi there!

I am trying to find a way of quickly identifying which of the stored procedures are user created (this is for my VFP upsizing wizard).

I have had a look at the SYSOBJECTS table with:

Code:
SELECT * FROM dbo.sysobjects where type = 'P'

...and the only difference I can see between a user and system created SP is that the field base_schema_ver has a zero value if it is user created.

I can therefore use this to spot user created SP's, ie:

Code:
SELECT * FROM dbo.sysobjects where type = 'P' and base_schema_ver = 0

..but only if this value doesn't change!

Could anyone tell me if this will be sufficient for my needs, or is there a better way to achieve what I am after?

TIA
Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Hi Mike!

Unfortunately not all begin with SP, I have some here that begin with DT_ (eg dt_addtosourcecontrol).

At the moment it's not too much of an issue, and it has just raised another thought in my head that I shouldn't be doing it anyway!! Our customers may have added their own for whatever reason so I shouldn't be deleting all user ones willy-nilly!

I am going to explicitly delete the ones we add instead and keep track of those in a table! Oh well, just trying to be lazy... ;-)


Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Neil,
In my db's sysobjects, all user-created SPs. have their category column populated with 0 and the system SP with 2.

The SQL Server BOL mentions that the category column is 'Used for publication, constraints, and identity.'

Code:
SELECT * FROM dbo.sysobjects where type = 'P' and category=0

or perhaps,
Code:
SELECT * FROM dbo.sysobjects where type = 'P' and category<>2

???

Rajesh
 
Hi Rajesh!

Thanks for the info!

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top