How can I determine if a SQL Server stored procedure parameter has a default?

后端 未结 7 1861
青春惊慌失措
青春惊慌失措 2020-12-11 03:08

Is there a way to determine programmatically if a SQL Server stored procedure parameter has a default? (Bonus points if you can determine what the default is.) SqlCommandB

7条回答
  •  情书的邮戳
    2020-12-11 03:53

    For stored procedures, I believe you would have to write something that parses T-SQL, or use the T-SQL parser that Microsoft provides.

    The parser and script generator live in two assemblies. The Microsoft.Data.Schema.ScriptDom contains provider agnostic classes and the Microsoft.Data.Schema.ScriptDom.Sql assembly contain classes for the parser and script generator that are SQL Server specific.

    How to specifically use this to identify the parameters and whether they're defaulted isn't covered and would be something you'd have to work on (probably with a deal of effort) using the sample code.

提交回复
热议问题