views:

287

answers:

2

I have an instance of SQL Server that I am trying to benchmark. From the SQL Studio application I can type

SET STATISTICS TIME ON

and see outputted statistics after that. From C++ code, I can do something like

SQLExecDirect(hstmt, "SET STATISTICS TIME ON", SQL_NTS);

and then retrieve these statistics via SQLError.

Is there a way to get at these statistics when accessing SQL Server over vanilla ODBC. In this case I am using Ruby's DBI:ODBC connector which works fine to connect and run queries but I haven't been able to figure out this meta stuff.

+1  A: 

Well, it's not going via odbc, but if you have the Sql Server tools, would the Sql Profiler work for you? You can use that to time the execution of statements, transactions, sprocs, and a myriad other things in Sql Server.

eidylon
It has to go over ODBC. Thanks, though.
Steven Canfield
I assume there's an overriding reason for not using the robust tools provided by the database manufacturer...
Bill Mueller
A: 

You could try using dbh.func(:stat)

jim0thy