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 attic shelves with a few shiny pots, many dusty ones and a vermilion broom leaning on the shelf

Remove Cached Plans Not Used for a Set Time in SQL Server

March 7, 2020
Pinal Dave
SQL Performance
Execution Plan, SQL Cache, SQL Scripts, SQL Server DBCC

To clear cached plans not used for a set time, list the plans by their last execution time or by the time they were built, then clear each one by its plan handle. This post builds a small procedure that previews the plans first and removes them only when you switch it on. It also explains why the plan handle needs its 0x prefix.

Read More
Several intact gears sit in a fitted case beside separate maintenance and inspection tools.

SQL SERVER Management Studio – Rebuild All Indexes on Table

March 6, 2020
Pinal Dave
SQL Tips and Tricks
SQL Index, SQL Scripts, SQL Server, SQL Server Management Studio

SSMS can open a Rebuild All dialog for table indexes. An e-commerce customer discovered this shortcut during my health check.

Read More
Gouache painting of a seedling tray with most cells sprouted and three empty, with a vermilion watering can beside it

Count NULLs in a Column in SQL Server: Five Ways Compared

March 5, 2020
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Group By, SQL NULL, SQL Scripts

To count NULLs in a column, filter with IS NULL and count the rows, or subtract COUNT(column) from COUNT(*). This post tests five ways on 100,000 rows and compares their page reads. It also counts NULLs in several columns at once and shows the NULL group in GROUP BY.

Read More
Gouache painting of a long tulip with a vermilion bloom in a short cream vase, with a second bloom lying beside it

ANSI_WARNINGS OFF: Why SQL Server Truncates Data Silently

March 3, 2020
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL Error Messages, SQL Scripts, SQL Server 2019

With ANSI_WARNINGS OFF, SQL Server cuts a string to fit its column and reports no error. This post runs the same insert with the setting on and off, and shows what else changes: variables, divide by zero and filtered indexes. It also shows how to check which setting a session uses.

Read More
Gouache painting of a heap of pears beside a grey wooden crate, a blue crate and an open vermilion crate

SELECT INTO Table Variable: Why It Fails and What to Use

March 2, 2020
Pinal Dave
SQL Tips and Tricks
SQL Scripts, SQL Table Operation, SQL Variable, Temp Table

SELECT INTO table variable fails with Msg 102 because SELECT INTO creates its target table and a table variable must be declared first. This post shows two working fixes, a declared table variable and a temp table. It also compares them on rollback, dynamic SQL and row estimates.

Read More
Two separate canoes are connected by a rope at the lakeshore

How to Join Two Tables Without Using Join Keywords? – Interview Question of the Week #266

March 1, 2020
Pinal Dave
SQL Interview Questions and Answers
SQL Joins, SQL Scripts, SQL Server

Question: How to Join Two Tables Without Using Join Keywords?

Answer: In my life, I have attended many interviews as an interviewer.

Read More
Gouache painting of felt cutouts of hearts, stars and suns on a table, with one heart vermilion

Smiley in SSMS: Show Emoji in Results and Database Names

February 28, 2020
Pinal Dave
SQL Tips and Tricks
SQL Collation, SQL Scripts, SQL Server Management Studio, Unicode

To show a smiley in SSMS, type the emoji inside an N-prefixed string and run the query. This post explains how SQL Server stores each emoji as two characters, why two different emoji can compare as equal, and how to find them in a column. It also shows what happens when an emoji is part of a database name.

Read More
Previous 1 … 45 46 47 48 49 50 51 … 365 Next
  • Books
  • Testimonials
  • Privacy Policy

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