How can i find the default values for a Stored Procedure parameter<font color="#0000ff" size=2> <p>I have a stored procedure, </p> <p>CREATE PROCEDURE</font><font size=2> [dbo]</font><font color="#808080" size=2>.</font><font size=2>[SReport] </p></font><font color="#808080" size=2> <p>(</p></font><font size=2> <p>@ListByBatch </font><font color="#0000ff" size=2>BIT</font><font color="#808080" size=2>,</p></font><font size=2> <p><strong>@UnPrintedOnly </strong></font><strong><font color="#0000ff" size=2>BIT</font><font size=2> </font><font color="#808080" size=2>=</font><font size=2> 1</p></font></strong><font color="#808080" size=2> <p>)</p></font><font color="#0000ff" size=2> <p>AS</p> <p>............................</p> <p>........</p> <p>I can find the information regarding parameters of this Stored Procedure from &quot;<font size=2>syscolumns&quot; or  </font></p> <p><font size=2>&quot;<font color="#008000" size=2>Information_Schema.Parameters&quot; system tables. These tables provides information about parametername, datatype ...etc. But dont provide information about default values for these parameters.</font></font></p> <p><font color="#008000">Here i have assigned a value, Does SQL Server stores this value????</font></p> <p><font size=2><font color="#008000" size=2>Does SQL Server maintains information about Default Values for Parameter ? (For tables it maintains the default value for a column).</font></font></p> <p><font size=2><font color="#008000" size=2>Is there any way , i can find All parameter information for a stored procedure including Default value..........????</p></font></font></font>© 2009 Microsoft Corporation. All rights reserved.Fri, 12 Dec 2008 05:43:16 Z900756fd-3980-48e3-ae59-a15d7fc15b4chttp://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c#900756fd-3980-48e3-ae59-a15d7fc15b4chttp://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c#900756fd-3980-48e3-ae59-a15d7fc15b4cViren Kapadiahttp://social.msdn.microsoft.com/Profile/en-US/?user=Viren%20KapadiaHow can i find the default values for a Stored Procedure parameter<font color="#0000ff" size=2> <p>I have a stored procedure, </p> <p>CREATE PROCEDURE</font><font size=2> [dbo]</font><font color="#808080" size=2>.</font><font size=2>[SReport] </p></font><font color="#808080" size=2> <p>(</p></font><font size=2> <p>@ListByBatch </font><font color="#0000ff" size=2>BIT</font><font color="#808080" size=2>,</p></font><font size=2> <p><strong>@UnPrintedOnly </strong></font><strong><font color="#0000ff" size=2>BIT</font><font size=2> </font><font color="#808080" size=2>=</font><font size=2> 1</p></font></strong><font color="#808080" size=2> <p>)</p></font><font color="#0000ff" size=2> <p>AS</p> <p>............................</p> <p>........</p> <p>I can find the information regarding parameters of this Stored Procedure from &quot;<font size=2>syscolumns&quot; or  </font></p> <p><font size=2>&quot;<font color="#008000" size=2>Information_Schema.Parameters&quot; system tables. These tables provides information about parametername, datatype ...etc. But dont provide information about default values for these parameters.</font></font></p> <p><font color="#008000">Here i have assigned a value, Does SQL Server stores this value????</font></p> <p><font size=2><font color="#008000" size=2>Does SQL Server maintains information about Default Values for Parameter ? (For tables it maintains the default value for a column).</font></font></p> <p><font size=2><font color="#008000" size=2>Is there any way , i can find All parameter information for a stored procedure including Default value..........????</p></font></font></font>Sun, 18 Feb 2007 06:15:21 Z2007-02-19T21:29:14Zhttp://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c#bd25b480-b0a4-44f4-85b6-c1843436745ehttp://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c#bd25b480-b0a4-44f4-85b6-c1843436745eEisahttp://social.msdn.microsoft.com/Profile/en-US/?user=EisaHow can i find the default values for a Stored Procedure parameter<font size=3><span style="font-family:Verdana,Geneva,Arial,Sans-serif">Hi,</span><br style="font-family:Verdana,Geneva,Arial,Sans-serif"><span style="font-family:Verdana,Geneva,Arial,Sans-serif">you can try </span></font><font style="font-family:Verdana,Geneva,Arial,Sans-serif" face="Times New Roman" size=3><font size=3><b>sp_procedure_params_rowset</b></font></font><font size=3><br style="font-family:Verdana,Geneva,Arial,Sans-serif"><br style="font-family:Verdana,Geneva,Arial,Sans-serif"></font><font style="font-family:Verdana,Geneva,Arial,Sans-serif" face="Times New Roman" size=3><font size=3><b>sp_procedure_params_rowset</b> will return the following result set.<br> <table border=1> <tbody><tr><td> PROCEDURE_CATALOG </td><td>Name of the database containing the procedure. </td></tr><tr><td>PROCEDURE_SCHEMA </td><td>Owner's name of the procedure. </td></tr><tr><td>PROCEDURE_NAME </td><td>Name of the procedure. </td></tr><tr><td>PARAMETER_NAME</td><td>Name of the parameter. </td></tr><tr><td>ORDINAL_POSITION </td><td>Ordinal position of the parameter. </td></tr><tr><td>PARAMETER_TYPE </td><td>If the parameter is an OUTPUT parameter or not. </td></tr><tr><td>PARAMETER_HASDEFAULT</td><td>If the parameter has a default value. </td></tr><tr><td>PARAMETER_DEFAULT</td><td>The default value of the parameter. </td></tr><tr><td>IS_NULLABLE</td><td>If the parameter accepts NULL values. </td></tr><tr><td>DATA_TYPE</td><td>Data type of the parameter. </td></tr><tr><td>CHARACTER_MAXIMUM_LENGTH</td><td>The maximum length of the parameter's data. </td></tr><tr><td>CHARACTER_OCTET_LENGTH</td><td>The maximum octect length of the parameter's data. </td></tr><tr><td>NUMERIC_PRECISION</td><td>The precision of the parameter. </td></tr><tr><td>NUMERIC_SCALE</td><td>The scale of the parameter. </td></tr><tr><td>DESCRIPTION</td><td>Description of the parameter. Always NULL. </td></tr><tr><td>TYPE_NAME</td><td>Actual name for the data type. </td></tr><tr><td>LOCAL_TYPE_NAME</td><td>Local name for the data type, if the data type is a user-defined data type. </td></tr></tbody></table> </font></font><font size=3><br style="font-family:Verdana,Geneva,Arial,Sans-serif"></font>Sun, 18 Feb 2007 08:25:57 Z2007-02-18T08:25:57Zhttp://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c#cca9f8c5-a303-45ba-b690-3c8913cdf422http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c#cca9f8c5-a303-45ba-b690-3c8913cdf422Viren Kapadiahttp://social.msdn.microsoft.com/Profile/en-US/?user=Viren%20KapadiaHow can i find the default values for a Stored Procedure parameter<p>Hi,</p> <p>Thanks for reply.</p> <p>I tried this , But it shows NULL for PARAMETER_DEFAULT and 0 for PARAMETER_HASDEFAULT though i have set default value for that parameter.</p> <p>Is there any other way , we can find this default value?</p> <p> </p>Mon, 19 Feb 2007 06:29:01 Z2007-02-19T06:29:01Zhttp://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c#5f58d353-f5fa-427e-9d8e-1be1080e3e20http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c#5f58d353-f5fa-427e-9d8e-1be1080e3e20Asvin Ananthanarayanhttp://social.msdn.microsoft.com/Profile/en-US/?user=Asvin%20AnanthanarayanHow can i find the default values for a Stored Procedure parameter<p>SQL SERVER does not store the default parameter values for transact sql stored procedure. It does so for clr stored procedures. See here</p> <p><a title="http://msdn2.microsoft.com/en-us/library/ms176074.aspx" href="http://msdn2.microsoft.com/en-us/library/ms176074.aspx">http://msdn2.microsoft.com/en-us/library/ms176074.aspx</a></p> <p>In SQL SERVER 2005, You can use object_definition() function to get the definition of the procedure and then parse it to get the default parameter values. </p> <p>In SQL 2K, the syscomments system table stores the definitions for the various stored procedures.</p>Mon, 19 Feb 2007 21:29:10 Z2007-02-19T21:29:14Zhttp://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c#11dabc71-9b44-4119-8483-2e72cb117eechttp://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c#11dabc71-9b44-4119-8483-2e72cb117eectymberwyldhttp://social.msdn.microsoft.com/Profile/en-US/?user=tymberwyldHow can i find the default values for a Stored Procedure parameter<font size=2><span style="font-family:Arial">Right, you won't be able to find these.  SQL Server parses a Stored Procedure everytime it runs it (no matter if it has an Execution Plan or not).  This allows for the Default values to take effect.  However, you'll never see these in any MetaData within SQL because it would take a lot of RegEx and parsing to actually determine what the Default values are, not to mention depending on the data type things could get really weird.  So that's why they don't do it.<br></span></font>Wed, 20 Aug 2008 19:55:11 Z2008-08-20T19:55:11Z