determining query cost programatically | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

determining query cost programatically

I know SQL server query analyzer provides a tool for determining the cost of a query. But my question is does anyone know how to do this programatically from java or c#? Is there a simple statment I can run against the connection or is there information in the meta data? Thanks for the help.
As far as I know this is something that SQL Server hasn’t yet exposed to the client environment. I hope YUKON (!!!) gives something like this. Gaurav
Man thrives, oddly enough, only in the presence of a challenging environment- L. Ron Hubbard

OK I’ve did a little more research and found that if I exectue this through query analyzer that the plan with all the cost values come back. But if I try to execute it via jdbc I don’t get any results back. Does anyone know why this is? SET SHOWPLAN_ALL ON
FROM tablename

Are you sure the results didn’t come back in a second resultset, I’ve heard of this happening before. Cheers
Shaun World Domination Through Superior Software
I checked there is not a second result set coming back. But for some reason when I execute the tope statment
It executes just fine, but it returns a value of -1 for it’s return value. Also when the next statment executes it does not return any records.

Check out this post: and zero in on my discussion with Chappy for an answer to your problem. Nathan H.O.