Solved

SQL Server TKPROF interface...

Posted on 2010-08-30
1
924 Views
Last Modified: 2012-06-27
I am trying to demonstrate to coders that correct approaches are priceless and in Oracle this is very simple.  SQL Server not so much (for me of course).

If you execute:

SELECT
  GETDATE()
, GETDATE()
, GETDATE()

that should have a very different "detailed" execution plan than

declare
  @v_Sysdate               as   smalldatetime    = GETDATE;

SELECT
  @v_Sysdate
, @v_Sysdate
, @v_Sysdate

Just trying to show the folks the internals so say, "hey, this is more maintainable, scalable, performance oriented, etc."

How can I do this?  How do I show that SQL Server would only get sysdate once (well GETDATE() once in SQL Server) with the declaration and 3 times with the first query?

Maybe this isn't the best example but I am trying to illustrate from a simple query to get these folks on board with correct coding paradigms.

Please help me illustrate how this is accomplished in SQL Server.

Thanks in advance,

B
0
Comment
Question by:cyimxtck
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 33557972
in sql server, you check the explain plan.

other settings:
SET SHOWPLAN_ALL ON
http://msdn.microsoft.com/en-us/library/ms187735.aspx

SET STATISTICS TIME ON
http://msdn.microsoft.com/en-us/library/ms190287.aspx

SET STATISTICS IO ON
http://msdn.microsoft.com/en-us/library/ms184361.aspx


0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now