Redgate logo
  • Products
    • All products
    • Automate database deployments
      • Flyway Enterprise
    • Monitor performance and availability
      • SQL Monitor
    • Standardize team-based development
      • SQL Prompt
      • SQL Search
      • Flyway
      • SQL Source Control
      • Source Control for Oracle
      • SQL Compare
      • Schema Compare for Oracle
      • SQL Data Compare
      • Data Compare for Oracle
    • Protect and preserve data
      • SQL Provision
      • Data Masker
      • SQL Clone
      • SQL Backup
      • SQL Data Catalog
    • .NET
      • .NET Developer Bundle
      • .NET Reflector
      • ANTS Performance Profiler
      • ANTS Memory Profiler
      • SmartAssembly
    • All products
      • .NET Developer Bundle
      • .NET Reflector
      • ANTS Memory Profiler
      • ANTS Performance Profiler
      • Data Compare for Oracle
      • Data Masker
      • Flyway
      • Schema Compare for Oracle
      • SmartAssembly
      • Source Control for Oracle
      • SQL Backup
      • SQL Clone
      • SQL Compare
      • SQL Data Catalog
      • SQL Data Compare
      • SQL Data Generator
      • SQL Dependency Tracker
      • SQL Doc
      • SQL Index Manager
      • SQL Monitor
      • SQL Multi Script
      • SQL Prompt
      • SQL Provision
      • SQL Scripts Manager
      • SQL Search
      • SQL Source Control
      • SQL Test
  • Solutions
    • Overview
    • By Need
      • Standardize
      • Automate
      • Monitor
      • Protect
    • By Role
      • Development
      • Operations
      • IT Management
      • Enterprise leadership
    • By Industry
      • Tech
      • Finance
      • U.S. Federal
      • Australian Government
      • Healthcare
      • Manager Service Providers
    • Resources
    • Maturity assessment
  • Our Company
    • Overview
    • Careers
    • Contact us
    • Redgate blog
    • Press kit
  • Support
  • Learning & community
    • Learning & community | Redgate Hub
    • Product articles
    • University
    • Events
    • Forums
    • Community
    • Simple Talk
  • Buy now
    • See all products
    • Request a quote
    • Contact sales
    • My account
    • Shopping cart
  • Products
    • All products
    • Automate database deployments
      • Flyway Enterprise
    • Monitor performance and availability
      • SQL Monitor
    • Standardize team-based development
      • SQL Prompt
      • SQL Search
      • Flyway
      • SQL Source Control
      • Source Control for Oracle
      • SQL Compare
      • Schema Compare for Oracle
      • SQL Data Compare
      • Data Compare for Oracle
    • Protect and preserve data
      • SQL Provision
      • Data Masker
      • SQL Clone
      • SQL Backup
      • SQL Data Catalog
    • .NET
      • .NET Developer Bundle
      • .NET Reflector
      • ANTS Performance Profiler
      • ANTS Memory Profiler
      • SmartAssembly
    • All products
      • .NET Developer Bundle
      • .NET Reflector
      • ANTS Memory Profiler
      • ANTS Performance Profiler
      • Data Compare for Oracle
      • Data Masker
      • Flyway
      • Schema Compare for Oracle
      • SmartAssembly
      • Source Control for Oracle
      • SQL Backup
      • SQL Clone
      • SQL Compare
      • SQL Data Catalog
      • SQL Data Compare
      • SQL Data Generator
      • SQL Dependency Tracker
      • SQL Doc
      • SQL Index Manager
      • SQL Monitor
      • SQL Multi Script
      • SQL Prompt
      • SQL Provision
      • SQL Scripts Manager
      • SQL Search
      • SQL Source Control
      • SQL Test
  • Solutions
    • Overview
    • By Need
      • Standardize
      • Automate
      • Monitor
      • Protect
    • By Role
      • Development
      • Operations
      • IT Management
      • Enterprise leadership
    • By Industry
      • Tech
      • Finance
      • U.S. Federal
      • Australian Government
      • Healthcare
      • Manager Service Providers
    • Resources
    • Maturity assessment
  • Our Company
    • Overview
    • Careers
    • Contact us
    • Redgate blog
    • Press kit
  • Support
  • Learning & community
    • Learning & community | Redgate Hub
    • Product articles
    • University
    • Events
    • Forums
    • Community
    • Simple Talk
  • Buy now
    • See all products
    • Request a quote
    • Contact sales
    • My account
    • Shopping cart

OVERVIEW

  • Compliant Database DevOps

BY NEED

  • Standardize team-based development
  • Automate database deployments
  • Monitor performance and availability
  • Protect and preserve data

BY ROLE

  • Development
  • Operations
  • IT Management
  • Enterprise leadership

BY INDUSTRY

  • Tech
  • Finance
  • U.S. Federal
  • Australian Government
  • Healthcare
  • Managed Service Providers

Redgate Hub

  • Product articles
  • University
  • Events
  • Forums
  • Community
  • Simple Talk

Product articles
SQL Prompt
Query Performance

  • SQL Prompt
  • SQL Code Analysis
  • Query Performance

SQL Prompt Code Analysis: A Hint is Used (PE004-7)

Phil Factor suggests a philosophy of "the SQL query optimizer knows best" when it comes to choosing the right execution plan. Use hints as a last resort, and evaluate them carefully whenever SQL Prompt warns you of their presence in your SQL code. Read more

  • SQL Prompt
  • SQL Code Snippets
  • Query Performance

Testing the Performance of Individual SQL Statements within a Batch using SQL Prompt

With SQL Prompt and Phil Factor's chk code snippet, you can, with a few clicks, get a list of all the SQL statements executed within a batch, in SSMS, their execution plans, and their execution statistics, such as duration, CPU, logical reads and so on. Read more

  • SQL Prompt
  • SQL Code Analysis
  • Query Performance

SQL Prompt Code Analysis: INSERT INTO a permanent table with ORDER BY (PE020)

Data in relational tables is never guaranteed to be returned in a particular order, so adding an ORDER BY to an INSERT INTO statement is meaningless and, pre-SQL Server 2012, could cause performance issues. If you really need to impose a particular order on rows in the table, use a Row_Number() window clause instead. Read more

  • SQL Prompt
  • SQL Code Analysis
  • Query Performance

Choosing Between Table Variables and Temporary Tables (ST011, ST012)

Phil Factor demonstrates the use of temporary tables and table variables, and offers a few simple rules to decide if a table variable will give better performance than a temp table (ST011), or vice-versa (ST012). Read more

  • SQL Prompt
  • SQL Code Analysis
  • Query Performance

When to use the SELECT…INTO statement (PE003)

SELECT…INTO is a useful shortcut for development work, especially for creating temporary tables. However, it no longer has a clear performance advantage and should be avoided in production code. It is better to use a CREATE TABLE statement, where you can specify constraints and datatypes in advance, making it less likely that inconsistencies will sneak into the data. Read more

  • SQL Prompt
  • SQL Code Analysis
  • Query Performance

Consider using [NOT] EXISTS instead of [NOT] IN with a subquery (PE019)

Phil Factor explains why you should prefer use of EXISTS over IN, when comparing data sets using a subquery. While there is no longer any significant performance advantage, using NOT EXISTS will avoid unexpected results when the subquery’s source data contains NULL values. Read more

  • SQL Prompt
  • SQL Code Analysis
  • Query Performance

Misuse of the scalar user-defined function as a constant (PE017)

The incorrect use of a scalar UDF as a global database constant is a major performance problem and should be investigated whenever SQL Prompt spots this in any production code. Unless you need to use these global constants in computed columns or constraints, it is generally safer and more convenient to store the value in an inline table-valued function, or to use a view. Read more

  • SQL Prompt
  • SQL Refactoring
  • Query Performance

How to Test SQL Server Functions and Procedures using SQL Prompt

Phil Factor shows how to create a table of input values versus expected results, and then use it to unit test your SQL stored procedures and functions and verify that they always produce the correct results. He uses SQL Prompt to make this task much simpler. Read more

  • SQL Prompt
  • SQL Code Analysis
  • Query Performance

Finding code smells using SQL Prompt: the SET NOCOUNT problem (PE008 and PE009)

Generally, you should prevent rowcount messages being sent, by adding a SET NOCOUNT ON at the start of every stored procedure, trigger and dynamically executed batch. Phil Factor demonstrates, and explains the nuances and exceptions. Read more

  • SQL Prompt
  • SQL Code Analysis
  • Query Performance

Finding code smells using SQL Prompt: procedures that lack schema-qualification (PE001)

SQL Prompt will warn you if it spots use of EXECUTE, without specifying the schema in which the stored procedure resides, because it can cause slower execution times, or even result in running of the wrong procedure. Read more

  • SQL Prompt
  • Query Performance

A day in the life of a developer with SQL Prompt

Write, refine, format and test a reporting query before lunch then refactor a database, and retest the new design, afterwards. All in a day's work for a developer armed with SQL Prompt. Read more

  • SQL Prompt
  • SQL Code Snippets
  • Query Performance

How to record T-SQL execution times using a SQL Prompt snippet

Phil Factor shares a SQL Prompt snippet called timings, which he uses as a standard testbed for getting execution times for procedures and functions. Read more

Products

  • SQL Monitor
  • SQL Prompt

Filter by level

Redgate Hub

  • Product Articles

    Product Articles

    Tips and how-to guides for Redgate products

  • University

    University

    Easy to follow video courses

  • Events

    Events

    Join us online, or get sponsored

  • Forums

    Forums

    Ask, discuss, and solve questions about Redgate's tools

  • Community

    Community

    Develop your skills and meet Redgate Advocates and Friends

  • Simple Talk

    Simple Talk

    In-depth articles and opinion from Redgate's technical journal

The Redgate Update Get the latest news and training with the monthly Redgate Update Sign up

Products

  • Automate
  • Monitor
  • Standardize
  • Protect & preserve

Support

  • Forums
  • Contact product support
  • Find my serial numbers
  • Download older versions

Solutions

  • Overview
  • Maturity Assessment

Our Company

  • Careers
  • Contact us
  • Redgate Blog
  • Our values

Community & Learning

  • Product Learning
  • University
  • Events & Friends
  • Simple Talk
  • Books
  • Forums

Partners

  • SQL Server Central
  • Resellers
  • Consulting partners

Privacy & compliance

  • Privacy and cookies
  • License agreement
  • Accessibility
  • Report security issue
  • Modern slavery
  • Gender pay gap report
  • CCPA - Do not sell my data

Follow us

Redgate on Twitter Redgate on LinkedIn Redgate on YouTube
  • Copyright 1999 - 2023 Red Gate Software Ltd