Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Server TKPROF interface...

Posted on 2010-08-30
1
Medium Priority
?
996 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 2000 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

610 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