Is there a way to determine if a parameter in a stored proc has a default value (and thus not required) in code - .Net?

后端 未结 4 1410
闹比i
闹比i 2021-01-19 02:59

I am already pulling the parameters from the stored proc sent in like this:

 foreach (SqlParameter param in cmd.Parameters)
            {
               if (         


        
4条回答
  •  离开以前
    2021-01-19 03:44

    To directly answer your question, no there is (probably) no way to determine if a stored procedure parameter possesses a default value 'in code' (i.e. using the SqlParameter class).

    In SQL Server (at least SQL Server 2005), you can query the system catalog view sys.parameters (and join it to the catalog view sys.procedures) and evaluate the value of the column has_default_value.

提交回复
热议问题