|
|
8000XXXX Errors ASP.NET 2.0 Classic ASP 1.0 Databases Access DB & ADO General SQL Server & Access Articles MySQL Other Articles Schema Tutorials Sql Server 2000 Sql Server 2005 General Concepts Search Engine Optimization (SEO)Search | ASP FAQ Tutorials :: Databases :: Schema Tutorials :: Schema: How do I show the parameters for a function or stored procedure? Schema: How do I show the parameters for a function or stored procedure?Let's say you have the following procedure:
Now, you're planning on calling this stored procedure in your ASP code or in an application, and you forget the parameter names and/or their datatypes. Well, the first thing you could do is look at the second resultset of sp_help:
However, this resultset does not differentiate between INPUT / OUTPUT parameters, nor does it show default values. There are a couple of built-in stored procedures that go into much greater detail about each parameter:
These give far more information than necessary, and still don't show default values for applicable params. You can also look at the syscolumns table:
Again, default values are not returned. Finally, you could create your own procedure using the PARAMETERS view under INFORMATION_SCHEMA, to give you a much more concise result:
Result:
Now, you'll notice if you run the following...
...that you *still* can't determine the default values. The sad truth is that these are simply not stored by SQL Server, they are merely evaluated by the text of the procedure at runtime. So, to determine default values, you're going to have to visually inspect the actual SP code, using sp_helptext or the ROUTINES view under INFORMATION_SCHEMA:
Please let us know if you have any tricks for determining default values programmatically (well, aside from brute force parsing, which is probably more work than resigning yourself to just look up the code for the rest of your life <G>). Related Articles Schema: How do I list all the indexes in a database? Schema: How do I list the databases on my server? Schema: How do I show all the primary keys in a database? Schema: How do I show all the triggers in a database? Schema: How do I show the columns for a table? Schema: How do I show the description property of a column? Schema: How do I show the stored procedures in a database? Schema: How do I show the tables in a database? Schema: How do I show the user-defined functions (UDFs) in a database? Schema: How do I show the views in a SQL Server database? |