views:

77

answers:

2

I have an application with some sql queries in a class, each query inside stringBuilders..

I've made another application to extract the query from each string builder parsing the code.

The point is: I need to generate an execution plan for each one of this queries.

Is there any way to do this automatically without coping and pasting the query to the SQL Management Studio?

A: 

A query execution plan largely depends on indexes within SQL Server. This determines if scans or seeks will be required for a particular join or look up. I'd say you can do part of an execution plan, but you'll never get everything just based on a query string.

Ian Suttle
A: 

Why do you need to generate the execution plan and what are you going to do with it?

If all you are wanting to do is to examine the query as it runs and determine if it is optimal or not then the "SQL Server Profiler" is the tool you are looking for. This will allow you to trace the queries issued by your application and examine the query plans without any cut and paste.

If you actually want to "do" something with the query plan data rather than just examine it then I'm afraid you are probably cutting and pasting either from SQL Server MS or from the profiler.

Steve Weet