Solved

SQL Server TKPROF interface...

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Distinct values from two tables 14 18
SQL Split character from numbers 3 16
Slow SQL query 12 17
sql query Help 12 17
Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
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…
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.

705 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

19 Experts available now in Live!

Get 1:1 Help Now