質問

I need to get each statement of given SQL Server stored procedure.

To achieve this, I generate execution plan XML and look for "StmtSimple" nodes in query.

This approach is quite slow for large procedures.

Is there any way that I can get every single statement of the procedure without generating XML execution plan?

役に立ちましたか?

解決

When you have the text of a stored procedure, you can perform a full parse on it using the TransactSql ScriptDom. If you just want to get each statement, it's possible to do that using this method.

However, I'm not convinced that it would actually perform much better than using the method you are using now. It's just another option to try.

Edit -> The ScriptDom is part of the SQL Server 2012 Feature Pack, and is contained in the 'SqlDom.msi' install.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top