Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Experts,

I have a sql query execution plan xml file, can i convert a execution plan xml to T-Sql query using .Net ?

Is there any helper classes ?

Please share your thoughts.

Thanks,
Ram
Posted

1 solution

Did you bother to open the .XML file in Notepad and take a look around??

There is no "converting" the execution plan back to a query statement. You can however, just open the file up in an XmlDocument and just grab the original query statement. It's in there in clear text.

There is no helper class in the .NET Framework to do this for you. You have to write the XML code to do it.
 
Share this answer
 
v2
Comments
Adersh Ram 10-Feb-14 12:45pm    
Hi Dave,

Thanks for your response.

Yes i know. I can open the file in a Text editor.....

Actually i am working on a Custom Tool that converts the SQL query with different syntax for another Application. Please look below sample query.

SELECT @SELECT:Employee.ID:ID@,
@SELECT:Employee.LAST_NAME:LAST_NAME@
FROM Employee
WHERE
@WHERE:SECURITY:RESOURCE:Employee.ID@ = 1

The tool convert a SQL query like above syntax. Need to extract the sql query, to know the Columns, table, where conditions for generation above query. I was thinking about the execution plan xml file. I know all the table and conditions and select details available in the execution plans.

Whats your thoughts?

Thanks,
Ram
Dave Kreskowiak 10-Feb-14 13:36pm    
You've got me confused. You said you wanted to import the execution plan (which I can only assume is exported from SQL Server Manager). The query string that I see doesn't match the format the you're showing.

Are you taking the query in the execution plan and converting it to this weird format (with the colons all over it)??
Adersh Ram 10-Feb-14 13:47pm    
I apologies you for my confusing question.

Yes, my plan is converting the query from the execution plan xml data. I couldn't find any other way to do that.

Is there any other better way to do this conversion?

Thank,
Ram
Dave Kreskowiak 10-Feb-14 14:58pm    
Nope. At least I've never heard of anyone or any library to do such a thing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900