Solved

SQL Server TKPROF interface...

Posted on 2010-08-30
1
971 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 143

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

717 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