Solved

SQL Server TKPROF interface...

Posted on 2010-08-30
1
932 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

785 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