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
An empty tile slot awaits an approved match from separately inspected replacement samples.

SQL SERVER – Altering Column – From NULL to NOT NULL

July 13, 2021
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Scripts, SQL Server

Altering Column nullability to NOT NULL requires resolving existing NULLs under an approved data rule. A customer used empty strings.

Read More
Gouache painting of a tray of mixed buttons beside four glass tubes of stacked buttons, the first tube filled with deep red buttons

Rowstore to Columnstore: Replace the Clustered Index

May 28, 2021
Pinal Dave
SQL Performance
ColumnStore Index, SQL Column, SQL Index, SQL Scripts

Rowstore to columnstore is a change of the clustered index, and one command works in only one case. This post builds two tables of 600,000 rows, shows the error from DROP_EXISTING on a primary key, and converts each table the working way. It compares the sizes before and after.

Read More
Gouache painting of a full wooden spool rack with one vermilion spool left over on the table

Maximum Columns in an Index: 32 Keys and the Way Around

March 22, 2021
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Index, SQL Scripts, SQL Statistics

The maximum columns in an index is 32 key columns, and a second limit on key size can stop an index earlier. This post builds a 40 column table, shows the error for a 33rd key column, and adds included columns to get around it. It also shows the 900 and 1,700 byte key limits and tests statistics on 33 and 40 columns.

Read More
Hatpins with repeated colored heads and one bare pin in a fabric cushion

COUNT(*), COUNT(column) and COUNT(DISTINCT): Basics That Trip People

March 5, 2021
Pinal Dave
SQL Tips and Tricks
Computed Column, SQL Column, SQL Server

Why do two counts of the same table disagree? Five tiny demos show NULL, blank text, LEFT JOIN placeholders, bigint and join multiplication.

Read More
An open fitted drawer and corresponding sample tray preserve their compartment sequence.

SQL SERVER – Get Column Names

February 25, 2021
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Scripts, SQL Server, SQL Stored Procedure

I Get Column names using a schema-qualified table and a defined column order. The four methods use corrected filters.

Read More
Gouache painting of a row of clay pots with the first few filled with soil and a vermilion scoop in a soil bag

DEFAULT WITH VALUES: Fill Existing Rows on a New Column

June 27, 2020
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Constraint and Keys, SQL NULL, SQL Scripts

DEFAULT WITH VALUES fills the rows that already exist when you add a column with a default. Without it, a nullable column keeps NULL in every old row. This post shows the three cases side by side, what a default never does, why the constraint needs a name, and how a large table takes the change in a millisecond.

Read More
Gouache painting of a chest of drawers pulled partly open, each drawer holding a sage ball of yarn and one vermilion ball

Find All Columns With a Specific Name in SQL Server

January 22, 2020
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Datatype, SQL Scripts, SQL Server

To find all columns with a specific name, query sys.columns and join sys.types for the data type. This post lists the matches with their schema, leaves out system objects, and then uses the same catalog to find names that appear with different data types.

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

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