Link to home
Start Free TrialLog in
Avatar of danblake
danblake

asked on

Generate Executed Execution Plan from SQL Server with OSQL

Hi Experts,

Does anybody know how to make the (Executed)  Execution Plan output from OSQL, just like it does from within Query Analyser ? (Possibly via a SET Command ? the SHOWPLAN options/are not suitable as this does not actually execute the statement and generates inconsistencies between the run / estimated run plans..)


Regards,

Dan.
Avatar of arbert
arbert

May not be as easy as you want it to be, but take a look at DBCC TRACEON using traceflag 310 or 317 in combination with trace flag 3604  You can tell it to log the plan that was actually used to a file.  This  is actually pretty cool because it gives TONS more information than a QA plan does.
Actually, hang on, those don't appear to work any more...let me look...
Looks like the above flags were holdovers from sybase--this is actually pretty interesting:

http://www.windowsitlibrary.com/Content/77/18/1.html
Avatar of danblake

ASKER

Just to clarify -- I'm using SQL Server 2000 & 7.  (Might need one version for each system, I understand that they do not always run the same on both systems.)
Its not getting any results back under sql-server 2000 (using QA) with these options at all ...
(This is more of a 6.5 option ?)
It is still a good article though..
ASKER CERTIFIED SOLUTION
Avatar of arbert
arbert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@arbert -- now you know that old question where a user was requesing what indexes are used on sps/views.. (cached execution plan...) instead of using sql-server profiler wouldnt' it be better to use this 'set statistics profile on' as it lists the indexes used (as long as you can generate a test work-load for every sp)... points are yours' arbert.  
This works and does the trick for me on my sql 2000 box...
Ya, I understand.  The whole "estimated" and "actual" plan is kind of a pain.  Especially if your talking para plans when it depends on the actual workload on the box too--sometimes it might run para, sometimes not.