For stored procedures there is currently no handling of optional parameters; all parameters are indicated to be non-optional.
I've been trying to find a way to find this information, for instance for information_schema, but the best (and only working) solution is the big blob of SQL from this comment [http://stackoverflow.com/a/15827063](http://stackoverflow.com/a/15827063)
Quite the complex and error-prone way to get the information though.
Has this been discussed ?
Comments: Perhaps it could be feasible to use Microsoft.SqlServer.Smo ? If you don't want to have a requirement for that to exist (comes with client tools sdk) then perhaps it could be loaded using reflection and if not present, use the current sql instead ? Example ``` var smo = Assembly.LoadWithPartialName("Microsoft.SqlServer.Smo"); dynamic instance = smo.CreateInstance("Microsoft.SqlServer.Management.Smo.Server", false, BindingFlags.CreateInstance, null, new object[] {"cbsqltest01"}, null, null); dynamic database = instance.Databases["HOSTNAME"]; foreach (dynamic sproc in database.StoredProcedures) { foreach (dynamic parameter in sproc.Parameters) { Console.WriteLine(sproc + ", " + parameter + ", " + (parameter.DefaultValue != "" ? parameter.DefaultValue : "No default value")); } } ```
I've been trying to find a way to find this information, for instance for information_schema, but the best (and only working) solution is the big blob of SQL from this comment [http://stackoverflow.com/a/15827063](http://stackoverflow.com/a/15827063)
Quite the complex and error-prone way to get the information though.
Has this been discussed ?
Comments: Perhaps it could be feasible to use Microsoft.SqlServer.Smo ? If you don't want to have a requirement for that to exist (comes with client tools sdk) then perhaps it could be loaded using reflection and if not present, use the current sql instead ? Example ``` var smo = Assembly.LoadWithPartialName("Microsoft.SqlServer.Smo"); dynamic instance = smo.CreateInstance("Microsoft.SqlServer.Management.Smo.Server", false, BindingFlags.CreateInstance, null, new object[] {"cbsqltest01"}, null, null); dynamic database = instance.Databases["HOSTNAME"]; foreach (dynamic sproc in database.StoredProcedures) { foreach (dynamic parameter in sproc.Parameters) { Console.WriteLine(sproc + ", " + parameter + ", " + (parameter.DefaultValue != "" ? parameter.DefaultValue : "No default value")); } } ```