Re: Establishing if procedure parameters are mandatory
- From: "Carl Kayser" <kayser_c@xxxxxxx>
- Date: Thu, 11 Oct 2007 07:39:24 -0400
"ThanksButNo" <no.no.thanks@xxxxxxxxx> wrote in message
news:1192074460.877648.20300@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Oct 5, 3:40 am, Mintcake <t...@xxxxxxxxxxxxxx> wrote:
Is there anywhere in the system catalogues (or elsewhere) that you can
look to see if a stored procedure parameter declaration has a default
parameter value specified. I don't need to know what the default is
(though that might be useful too) just want to know if the parameter
must be specified in the call.
Try this:
select c.text
from syscomments c,
sysobjects o,
sysusers u
where 1=1
and c.id = o.id
and o.uid = u.uid
and o.name = '{name of procedure}'
and u.name = '{name of owner}'
order by
c.colid
That gives you the full text of the stored procedure in question.
I'm not familiar enough with how stored procedures to tell you what to
look for, but if you look through there, it ought to be fairly
obvious.
If you're looking for something automatic
(e.g., IF HasDefaults(proc) THEN)
then I'm afraid I can't help.
:-(
Quibble - "where 1=1" is obviously unnecessary. And sysusers can be
eliminated via "and o.uid = user_id ('{name of owner}')". Very large procs
should be ordered by, if I remember correctly, colid2, colid.
The expected source of the absence/presence of a default would be
syscolumns.cdefault. Unfortunately the value is always zero for a stored
procedure argument whereas it will be non-zero for a table column that has a
default. I suspect that it always zero for a view column as well.
.
- Follow-Ups:
- Re: Establishing if procedure parameters are mandatory
- From: ThanksButNo
- Re: Establishing if procedure parameters are mandatory
- References:
- Establishing if procedure parameters are mandatory
- From: Mintcake
- Re: Establishing if procedure parameters are mandatory
- From: ThanksButNo
- Establishing if procedure parameters are mandatory
- Prev by Date: Re: SELECT to return records with dates
- Next by Date: Example of how to call a stored procedure from C using dblib - needed desperately
- Previous by thread: Re: Establishing if procedure parameters are mandatory
- Next by thread: Re: Establishing if procedure parameters are mandatory
- Index(es):
Relevant Pages
|