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
Two cream tickets with matching red circles sit beside one blue parcel in a wooden compartment.

SQL Server: Why Retrying an INSERT Can Create Duplicate Rows

June 15, 2014
Pinal Dave
SQL Tips and Tricks
SQL Constraint and Keys, SQL Scripts, SQL Server

Retrying an INSERT can create duplicate rows even with an identity primary key. These tested examples use a stable request ID to return the original order, reject changed inputs, and preserve unrelated errors.

Read More
SQL SERVER - Drop All the Foreign Key Constraint in Database - Create All the Foreign Key Constraint in Database

SQL SERVER – Drop All the Foreign Key Constraint in Database – Create All the Foreign Key Constraint in Database

April 11, 2014
Pinal Dave
SQL Tips and Tricks
SQL Constraint and Keys, SQL Scripts

Need to drop all the foreign key constraints in a database and create them again? Here is a script by SQL expert Swastik Mishra that does both.

Read More
A cork puller beside two evenly sealed bottles and one raised tilted cork

Assertion Queries: Data Checks That Should Return Zero Rows

March 22, 2014
Pinal Dave
SQL Tips and Tricks
SQL Constraint and Keys, SQL Sub Query, Testing

Let a short query find the order with no lines before a customer does. A small demo shows the failing keys, constraint error 547 and a clean repair.

Read More
Displaying table and columns for SQL query.

SQL SERVER – Listing Primary Key of Table with Stored Procedure sp_pkeys

March 2, 2014
Pinal Dave
SQL Tips and Tricks
SQL Constraint and Keys

Here is how to list the primary key of a table with the stored procedure sp_pkeys, a follow up to my earlier post on sp_fkeys.

Read More
Sp_fkeys output window.

SQL SERVER – Listing Foreign Key Relationships of Table with Stored Procedure sp_fkeys

March 1, 2014
Pinal Dave
SQL Tips and Tricks
SQL Constraint and Keys

A quick trick to list all the foreign key relationships of a table with the stored procedure sp_fkeys, with a sample script on AdventureWorks2012.

Read More
A finger pressing an already glowing lift call button a second time beside a closed brass lift door.

Stopping Duplicate API Requests With an Idempotency Key Table

January 28, 2014
Pinal Dave
SQL Tips and Tricks
Best Practices, SQL Constraint and Keys, SQL Server, SQL Transactions

Store an idempotency key with its order in one transaction, return the committed result on retries, and define key reuse and expiry rules.

Read More
A figure struggles with a chain.

SQL SERVER – Create Unique Constraint on Table Column on Existing Table

January 11, 2014
Pinal Dave
SQL Tips and Tricks
SQL Constraint and Keys

Can you create unique constraint on a column of a table that already exists? Yes. Here is the short ALTER TABLE ADD CONSTRAINT script I use.

Read More
Previous 1 … 5 6 7 8 9 10 11 … 24 Next
  • Books
  • Testimonials
  • Privacy Policy

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