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 wall of small drawers with one pulled open showing a vermilion key

Show Primary Key of a Table in SQL Server With sp_pkeys

August 14, 2019
Pinal Dave
SQL Tips and Tricks
SQL Constraint and Keys, SQL Scripts, SQL Stored Procedure, System Object

To show primary key columns for one table, call sp_pkeys with the table name. This post builds a small demo database, reads a single column and a composite key, and handles schemas and errors. It also lists every key in a database with one catalog query.

Read More
Two toggle clamps securing a wooden piece against separate reference blocks

Foreign Key Checks in Insert Plans: The Cost of Each Constraint

June 13, 2019
Pinal Dave
SQL Tips and Tricks
Primary Key, SQL Constraint and Keys, SQL Server

Before you drop a foreign key to speed up a load, look at what it costs. This walk-through shows the Assert, the two parent lookups, and the trust trap.

Read More
A revolving punch making one specified round hole beside differently shaped test holes

Enforcing Formats With a REGEXP_LIKE Check Constraint

June 10, 2019
Pinal Dave
SQL Tips and Tricks
Comprehensive Database Performance Health Check, SQL Constraint and Keys, SQL Server

Stop badly shaped product codes before they reach a report. A short, tested walk-through of anchors, NULLs and adding the rule to old data.

Read More
Two sealed envelopes on a tray illustrate why verification matters

What is Trusted Constraint in SQL Server? – Interview Question of the Week #210

January 27, 2019
Pinal Dave
SQL Interview Questions and Answers
SQL Constraint and Keys, SQL Performance, SQL Scripts, SQL Server

What is a trusted constraint in SQL Server? Many experts do not know, so instead of a definition I explain it with a simple check constraint example.

Read More
Gouache painting of a vermilion cart carrying three small stacked wooden tables

Drop Multiple Tables with One DROP TABLE Statement

October 23, 2018
Pinal Dave
SQL Tips and Tricks
SQL Constraint and Keys, SQL Scripts, SQL Table Operation

To drop multiple tables in SQL Server, list them in one DROP TABLE statement, referencing tables first. This post tests the order rule on a parent and child table and shows what happens after an error. It also covers IF EXISTS, drops by name pattern and temporary tables.

Read More
Two primary keys are each attached to a different physical index structure

How to Create Primary Key Without ANY Index? – Interview Question of the Week #143

October 8, 2017
Pinal Dave
SQL Interview Questions and Answers
SQL Constraint and Keys, SQL Scripts, SQL Server

Question: How to create primary key without ANY index? SQL Server builds a clustered or nonclustered index for every primary key, so here is the answer.

Read More
Execution Plan of SQL Query.

SQL SERVER – How to Find UNIQUE Key Columns? – sp_special_columns

September 8, 2017
Pinal Dave
SQL Tips and Tricks
SQL Constraint and Keys, SQL Scripts, SQL Server, SQL Stored Procedure

Want to know which columns uniquely identify a row in a table? The system stored procedure sp_special_columns tells you. Here is a quick demo.

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

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