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 board of cream and slate blue buttons under a magnifying glass with a vermilion handle

Count a Particular Value Across All Columns in SQL Server

December 28, 2018
Pinal Dave
SQL Tips and Tricks
PIVOT and UNPIVOT, SQL Column, SQL Scripts, SQL Server

To count a particular value across all columns of a table, use a CASE sum, CROSS APPLY with VALUES, UNPIVOT or UNION ALL. This post tests all four on a staff contact table, compares their reads on 200,000 rows, and builds the column list with dynamic SQL.

Read More
A small red flag marking one foxglove in a garden border with no fence around it

Tagging Personal Data Columns With ADD SENSITIVITY CLASSIFICATION

November 28, 2018
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Documentation, SQL Server, SQL Server Security

Add sensitivity classification to reviewed columns, inspect stored labels, and keep discovery separate from encryption and access controls.

Read More
A turf edger changing one grass border while the rest of the patch remains intact

JSON_MODIFY: Changing One Property Inside a JSON Column

July 25, 2018
Pinal Dave
SQL Tips and Tricks
Computed Column, JSON, SQL Column

Edit one value inside a JSON document without string surgery. A hands-on tour of the quirks with types, NULL, missing paths and retries.

Read More
Opaque cord sleeves with matching and different crimped profiles beside crimping pliers

Blind Index: Searching an Encrypted Column Without Decrypting

July 11, 2018
Pinal Dave
SQL Performance
ColumnStore Index, Computed Column, SQL Column, SQL Index

Encrypted emails cannot be searched, so store a keyed digest beside them. A hands-on demo of how it works, what it leaks and how rotation hurts.

Read More
Gouache painting of a wooden pigeonhole cabinet filled with blocks except one slot, with a vermilion block waiting beside it

Change Column From NULL to NOT NULL in SQL Server

January 12, 2018
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Datatype, SQL NULL, SQL Scripts

To change a column from NULL to NOT NULL, first fill every NULL value, then run ALTER COLUMN with the full data type and NOT NULL. This post shows the Msg 515 error you get otherwise, how to choose the replacement value, and the trap that makes a column nullable again. It ends with a default constraint that keeps new rows valid.

Read More
A clay blank and two differently shaped molds sit beside a fitted sample.

SQL SERVER – Puzzle – Brain Teaser – Changing Data Type is Changing the Default Value

December 8, 2017
Pinal Dave
SQL Puzzle
SQL Column, SQL Datatype, SQL NULL, SQL Server

Changing the Default Value is the question behind this data-type puzzle. I keep the expression, data type and nullability separate.

Read More
Gouache painting of a shelf of identical clay flowerpots with seedlings, the second pot painted vermilion

COL_NAME Function in SQL Server: Get a Column Name by ID

July 31, 2017
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Function, SQL Index, SQL Scripts

The COL_NAME function returns a column’s name when you give it a table’s object ID and the column’s ID. This post uses it to turn the column IDs in index views into names, shows why a column ID is not a position once a column has been dropped, and explains the trap that returns a wrong name when the table lives in another database.

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

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