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 tray of cream, sage and slate thread spools with one spool wearing a vermilion ring

Nullable Columns in a Database: List Them and Count NULLs

December 12, 2019
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL NULL, SQL Scripts

Nullable columns in a database cost you ISNULL calls and OR IS NULL conditions in every query. This post lists them with a catalog query, compares the INFORMATION_SCHEMA version, and counts the real NULLs in each column. The count tells you which columns can become NOT NULL and which can go.

Read More
A potato spiralizer preserving a fine ribbon beside coarse whole potato pieces

AVG of an Integer Column Returns an Integer: Getting Decimals Back

October 3, 2019
Pinal Dave
SQL Tips and Tricks
Computed Column, SQL Column, SQL Server

The dashboard says the average is 1 when everyone can see it is 1.5. Here is why AVG does that and the one-line fix.

Read More
Gouache painting of three flower stems clipped in one cut by vermilion shears on a florist's bench

Drop Multiple Columns in One ALTER TABLE Statement

October 2, 2019
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Scripts, SQL Table Operation

To drop multiple columns, list them after one DROP COLUMN in one ALTER TABLE statement. This post tests the syntax on a table with a default, a check constraint and an index, shows the error that a dependent object causes and drops the constraints and columns together. It also explains why the disk space doesn’t return until a rebuild.

Read More
Gouache painting of six small tins on a sewing table, three open with buttons and a vermilion magnifying glass in front

Tables Containing a Column: Search by Name in SQL Server

September 9, 2019
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Scripts, SQL Server, SQL System Table

To find tables containing a column, search sys.columns by name instead of opening tables one by one. This post searches one database, then every database on the server, and shows why an underscore in the pattern needs brackets. It also compares the data types of related columns.

Read More
Illustrated cover: Swap Without a Temp

SQL SERVER – Swap Column Values In Table

July 16, 2019
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Scripts, SQL Server

Here is a question asked to me during Comprehensive Database Performance Health Check. The question was about how to swap column values in a table.

Read More
A large open steamer trunk in an attic holding only a few linens, some matching socks and one long red umbrella.

Profiling a Table’s Data: Nulls, Distinct Values and Lengths

July 2, 2019
Pinal Dave
SQL Tips and Tricks
DBA, SQL Column, SQL Datatype, SQL NULL, SQL Server

Start profiling a table’s data with null counts, distinct values, lengths, and generated checks that expose misleading column definitions.

Read More
50 Length shown in Varchar.

SQL SERVER – Measuring the Length of VARCHAR and NVARCHAR Columns with COL_LENGTH

December 29, 2018
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Datatype, SQL Function, SQL Scripts, SQL Server

Does an NVARCHAR column take twice the space of VARCHAR? Yes. I measure the length of VARCHAR and NVARCHAR columns with COL_LENGTH to show it.

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

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