Scripts

Technical Article

Primary Keys which are not Clustered Indexes in a database

Recently I was asked to find all the Primary keys that are not clustered Indexes in the database. I constructed the below script which will help us to locate the primary keys in the database which are not clustered index.

(5)

You rated this post out of 5. Change rating

2013-09-18 (first published: )

1,935 reads

Blogs

Excellent article on securing msdb

By

Fabiano Amorim has written an excellent article at Simple Talk on securing msdb. Here's...

T-SQL Tuesday #201: Temp Tables

By

This month we have a new host, which I am grateful for. So many...

When Do You Reach For A #temp Table?

By

I needed to do some research because there is more to #temp tables than...

Read the latest Blogs

Forums

OUTER APPLY Fundamentals: Part 2

By Imran2629

Comments posted to this topic are about the item OUTER APPLY Fundamentals: Part 2

Building Great Software

By Steve Jones - SSC Editor

Comments posted to this topic are about the item Building Great Software

The Range of Customers

By Steve Jones - SSC Editor

Comments posted to this topic are about the item The Range of Customers

Visit the forum

Question of the Day

The Range of Customers

I have this data in the OrderHeader table in a SQL Server 2025 database (ordered by CustomerID ASC):

orderid orderdate               customerid complete
3       2025-05-10 00:00:00.0002          1
21      2024-01-10 00:00:00.0003          1
15      2023-10-28 00:00:00.0004   1
13      2025-03-08 00:00:00.0006          1
11      2024-04-02 00:00:00.0007          1
If I run this query, how many rows are returned?
SELECT *
 from dbo.OrderHeader
 where customerid between 3 and '6'

See possible answers