SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Creating Functions for Stored Procedures


Creating Functions for Stored Procedures

Author
Message
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (115K reputation)SSC Guru (115K reputation)SSC Guru (115K reputation)SSC Guru (115K reputation)SSC Guru (115K reputation)SSC Guru (115K reputation)SSC Guru (115K reputation)SSC Guru (115K reputation)

Group: General Forum Members
Points: 115539 Visits: 41423
jcrawf02 (10/10/2008)
Just curious, if you are working in an environment where DBA's DON'T know not to use sp_, is there another way to filter out the system procs and keep the rest?


Yes...

If you use Information_Schema.Routines as the source of information, only user objects are listed. You can also brute force things using one of the following...

WHERE OBJECTPROPERTY(id , 'IsMsShipped') = 0

WHERE OBJECTPROPERTY(OBJECT_ID(tablenamecolumn) , 'IsMsShipped') = 0

WHERE OBJECTPROPERTY(OBJECT_ID(schemanamecolumn+'.'+tablenamecolumn) , 'IsMsShipped') = 0



--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Alex Grinberg-230981
Alex Grinberg-230981
SSC-Enthusiastic
SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)

Group: General Forum Members
Points: 176 Visits: 414
Thanks to everyone for good response (and bad as well). Sorry for broken C# link, but it’s nothing to do with the article.
Alex Grinberg-230981
Alex Grinberg-230981
SSC-Enthusiastic
SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)SSC-Enthusiastic (176 reputation)

Group: General Forum Members
Points: 176 Visits: 414
You could use select * from sys.objects where is_ms_shipped = 0 as well. I am not INFORMATION_SCHEMA fan. This is personal preference.BigGrin
Steve Jones
Steve Jones
SSC Guru
SSC Guru (82K reputation)SSC Guru (82K reputation)SSC Guru (82K reputation)SSC Guru (82K reputation)SSC Guru (82K reputation)SSC Guru (82K reputation)SSC Guru (82K reputation)SSC Guru (82K reputation)

Group: Administrators
Points: 82381 Visits: 19222
The link has been corrected in the article.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (115K reputation)SSC Guru (115K reputation)SSC Guru (115K reputation)SSC Guru (115K reputation)SSC Guru (115K reputation)SSC Guru (115K reputation)SSC Guru (115K reputation)SSC Guru (115K reputation)

Group: General Forum Members
Points: 115539 Visits: 41423
Alex Grinberg (10/10/2008)
You could use select * from sys.objects where is_ms_shipped = 0 as well. I am not INFORMATION_SCHEMA fan. This is personal preference.BigGrin


Heh... I forgot about that. I'm still a bit stuck in the world of 2k. Thanks for the reminder. Smile

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
msorens
msorens
SSC-Enthusiastic
SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)

Group: General Forum Members
Points: 160 Visits: 184
Alex:
Technical folks are busy people. Like me, they probably scan through a lot of articles very quickly, the vast majority of which are either (a) not relevant to them or (b) poor code or poor writing. Because I find your writing reasonable and your topics interesting, I thought it would be worthwhile to offer one tip, as a fellow author (http://cleancode.sourceforge.net/wwwdoc/articles.html). The general principal that applies to many things is this:

Make it easy for people to do business with you.

Applying this to the context of writing this becomes:

Make it easy for people to see why your article is useful to them.

I almost skipped your article because I had to scan and rescan and rescan again until I could say "Oh, yes. That is useful to know." What I would have found most useful--and no doubt others would as well--is to FIRST provide a concrete example, as in: "Say in your DB you have a GetMapDetails stored procedure which takes parameters x and y, and a InsertNewCustDetails stored procedure which takes parameters a, b, and c. If you run my SQL-to-.NET function creator, this will provide a .cs or .vb file containing this code: ."
cliffb
cliffb
SSC Eights!
SSC Eights! (925 reputation)SSC Eights! (925 reputation)SSC Eights! (925 reputation)SSC Eights! (925 reputation)SSC Eights! (925 reputation)SSC Eights! (925 reputation)SSC Eights! (925 reputation)SSC Eights! (925 reputation)

Group: General Forum Members
Points: 925 Visits: 438
A couple of options depending on your version of SQL to exclude microsoft objects.

In SQL 2005, there is a field called is_ms_shipped. It's a bit value. 1 means it's a microsoft object, 0 if it is not.

SELECT name
FROM sys.objects
WHERE type = 'p' and name not like 'sp[_]%' AND is_ms_shipped=0
ORDER BY name



To use this in SQL 2000 you would modify the SQL code to this:

SELECT name
FROM sysobjects
WHERE type = 'p' and name not like 'sp[_]%' AND OBJECTPROPERTY(object_id,'isMSShipped')=0
ORDER BY name




Thanks for sharing this code.



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search