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 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 shoulder yoke carrying one bucket of stones while a second load waits beside it

Disk Space Needed to Build a Clustered Index on a Big Table

April 11, 2018
Pinal Dave
SQL Performance
Clustered Index, SQL Table Operation, Table Partitioning, Temp Table

A clustered index build holds the old table and the new index at the same time. Here is a small demo of that peak, and what to check first.

Read More
Colored axle collars being exchanged while cotter pins and chains stay attached

Renaming a Table With Almost No Downtime Using sp_rename

March 29, 2018
Pinal Dave
SQL Tips and Tricks
SQL System Table, SQL Table Operation, Table Partitioning, Temp Table

A rename swaps names in a blink, yet the foreign key and permissions stay with the old table. Here is a short demo and a safer swap.

Read More
Some temporary sand structures remain while the tide erases others

How Many Temporary Tables are Created So Far in SQL Server? – Interview Question of the Week #149

November 26, 2017
Pinal Dave
SQL Interview Questions and Answers
SQL Scripts, SQL Server, Temp Table

How many temporary tables are created so far in SQL Server? No DMV gives this directly, but here is an easy workaround to find the answer.

Read More
Gouache painting of a small tent beside a large open-sided vermilion canopy over a picnic table

Create a Global Temporary Table in SQL Server

October 21, 2017
Pinal Dave
SQL Tips and Tricks
SQL Scripts, SQL Server, SQL TempDB, Temp Table

A global temporary table starts with two # signs, lives in tempdb, and any session can read it. This post creates one, reads it from a second window, and shows when SQL Server drops it. It also covers name collisions and the cases where a different table type is the better choice.

Read More
Two temporary tile workspaces have different physical boundaries and one tile in each.

SQL SERVER – How to Create Table Variable and Temporary Table?

October 18, 2017
Pinal Dave
SQL Tips and Tricks
SQL Scripts, SQL Server, SQL TempDB, Temp Table

A Temporary table uses CREATE TABLE, while a table variable uses DECLARE. I use one row in each beginner example.

Read More
Previous 1 2 3 4 5 6 7 8 … 11 Next
  • Books
  • Testimonials
  • Privacy Policy

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