How can I retrieve SQL Stored Procedure Parameter's with SMO more efficently?

淺唱寂寞╮ 提交于 2019-12-05 14:27:04

I had a smiliar problem and found that if you use...

svr.SetDefaultInitFields(typeof(StoredProcedure), false)

It's way faster. I'm asuming that with any other options it actually fetches everything but if you switch it off then just get your params the speed increase is huge. Mine when from 5-6 secs to 0.5 secs for a 10 param sp. Still not quite perfect but livable with.

EDIT

Since playing with this a little more I found that the typeof(StoredProcedure) level appraoch works the best. In my tests using the typeof(StoreedProcedureParameter) option was consistently 1.5 secs or so compared to the 0.5 secs or so with the typeof(StoredProcedure) version.

I'd be interested if anyone could tell me why?

You could use a parser to retrieve the default values from the stored procedure, e.g. Microsoft.Data.Schema.ScriptDom.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!