This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
Gouache painting of a wooden hopper pouring wheat in and flour out into a bowl, with the hopper painted vermilion

Dynamic SQL Output Parameter: Pass Values In and Out Safely

July 23, 2020
Pinal Dave
SQL Tips and Tricks
Dynamic SQL, SQL Scripts, SQL Stored Procedure

A dynamic SQL output parameter lets a statement built at run time hand a value back to the caller. This post shows input, output and input/output parameters with sp_executesql, explains the errors you meet, and measures why parameters beat concatenation: one reusable plan instead of ten, and no injection.

Read More
Gouache painting of wooden frames in different shapes each holding a pebble, with the diamond frame in vermilion

QUOTENAME Function: Custom Quote Characters and Dynamic SQL

July 27, 2019
Pinal Dave
SQL Tips and Tricks
Dynamic SQL, SQL Function, SQL Scripts, SQL String

The QUOTENAME function turns a name into a safe identifier and doubles any closing delimiter inside it. Tested queries show which quote characters work, the 128 character limit and a dynamic SQL example. A short card lists the rules.

Read More
Gouache painting of a small drawer cabinet on a sewing table with a vermilion thread spool inside one open drawer

Temp Table Scope in Dynamic SQL: Who Can See What

July 22, 2019
Pinal Dave
SQL Tips and Tricks
Dynamic SQL, SQL Scripts, SQL TempDB, Temp Table

Temp table scope decides what dynamic SQL and stored procedures can read. Tested demos show a child reading a parent table, a procedure that fails without it, a dynamic table shape and the error a typo causes. A card lists the rules.

Read More
Gouache painting of a long vermilion fruit bowl in a market aisle with small private baskets under the counter

Dynamic SQL Temp Table: Why It Disappears and How to Keep It

July 20, 2019
Pinal Dave
SQL Tips and Tricks
Dynamic SQL, SQL Scripts, SQL TempDB, Temp Table

A dynamic SQL temp table is dropped when its dynamic batch ends, so the main code cannot read it. A global temp table keeps the data, and a per session name keeps it safe. Every step is tested, including the second session clash.

Read More
A blank wooden fingerpost on a moor, one arm pointing to the stone footings of a vanished cottage

Finding Procedures That Reference Databases That No Longer Exist

March 13, 2019
Pinal Dave
SQL Tips and Tricks
DBA, Dynamic SQL, SQL Dependency, SQL Stored Procedure

Find procedures that reference databases missing from the instance, retain review coverage, and check dynamic SQL and synonyms separately.

Read More
Escargot tongs returning one shell from a deep vessel to a shallow plate

sp_executesql Output Parameters: Getting Values Back From Dynamic SQL

January 19, 2019
Pinal Dave
SQL Tips and Tricks
Dynamic SQL, Output Clause, SQL Server

Dynamic SQL runs in its own scope, so a value only comes back if you ask twice. Here are the two mistakes that leave you with NULL.

Read More
A garden hose nozzle with a red dial, one sharp jet and one wide gentle shower over flower beds

Catch-All Queries and Optional Parameter Plan Optimization in SQL Server 2025

January 18, 2019
Pinal Dave
SQL Performance
Dynamic SQL, Parameter Sniffing, Recompile, SQL Server

Compare catch-all queries with recompilation, parameterized dynamic SQL, and SQL Server 2025 optional parameter plan optimization.

Read More
1 2 3 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com