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
Moderator
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
go SELECT *
FROM tablename
go SET SHOWPLAN_ALL OFF
go

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
SET SHOWPLAN_ALL ON
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: http://www.sql-server-performance.com/forum/topic.asp?TOPIC_ID=927 and zero in on my discussion with Chappy for an answer to your problem. Nathan H.O.
Moderator
SQL-Server-Performance.com
]]>