Is there any way to determine from within SQL Server (I'm on 2012 FYI) if a SP's parameters have default values? There are other threads on this, however the suggestions don't seem to get me this information accurately.
Here are a couple of things I've tried;
select *
from sys.objects so join sys.parameters sp on so.object_id = sp.object_id
where so.type='P'
and so.name = 'someSp'
The above query returns a number of columns that sound like I'm barking up the right tree (has_default_value, default_value among them) but these don't seem to vary whether I have a default value in my SP or not. (has_default value is always 0, default_value is always null)
exec sp_sproc_columns 'someSp'
Same deal; the above SP returns a number of columns including NULLABLE and IS_NULLABLE; NULLABLE is always equal to 1 and IS_NULLABLE = YES, regardless of my SP contents.
A note; SQL Server management studio clearly displays the metadata associated with a each SP Parameter.
I've used SQL Profiler to examine what happens when I view the parameters of a SP in Management Studio's Object Explorer. When you expand the parameters folder, there are two queries run. The first query is a bit long for pasting here (though I'll do so if helpful). It contains a column called DEFAULT VALUE; however it's always NULL as far as I can tell. The second query simply returns the body of the SP; presumably to output to the text editor window (though I'm afraid there could be some parsing happening within mgmt studio!)
For reference / just to make sure I'm not losing my marbles I've created two meaningless Sps just for testing. They look like:
CREATE PROCEDURE TestDefaultSpValue_Default
@I INT = 2
AS
BEGIN
SET NOCOUNT ON;
SELECT @I
END
CREATE PROCEDURE TestDefaultSpValue_NoDefault
@I INT
AS
BEGIN
SET NOCOUNT ON;
SELECT @I
END