Find Primary Column of all tables in database
This code helps in finding Primary Keys for all tables in a database.
2012-10-02 (first published: 2012-09-04)
1,445 reads
This code helps in finding Primary Keys for all tables in a database.
2012-10-02 (first published: 2012-09-04)
1,445 reads
Output table of gaps in a primary key across multiple databases on same, remote and/or linked servers.
2011-08-29 (first published: 2011-08-12)
960 reads
This is the first of a series of articles to analyze the use of surrogate keys in different scenarios.
2010-10-25
14,118 reads
2010-07-15
3,941 reads
Following script will list out all the columns which have unique/primary key constraints for a given table.
2009-01-02 (first published: 2008-12-10)
1,284 reads
2008-11-04
1,965 reads
By SQLPals
Why sys.fn_dblog Is Undocumented And Why It's Still There Why sys.fn_dblog...
When I put together the invitation for T-SQL Tuesday #202, I wasn't sure what...
By Steve Jones
My life has some crazy travel stretches for sure. Between speaking, office visits, customer...
Comments posted to this topic are about the item Implementing Type 4 Slowly Changing...
Comments posted to this topic are about the item The Disabled Index
Comments posted to this topic are about the item Server-Level Table sizes
I run this code on SQL Server 2022.
CREATE TABLE Drink
(
drinkid INT NOT NULL
CONSTRAINT DrinkPK PRIMARY KEY CLUSTERED,
drinkname VARCHAR(20),
rating NUMERIC(2, 1)
)
GO
INSERT INTO Drink
(
drinkid,
drinkname,
rating
)
VALUES
(1, 'Margarita', 4.5),
(2, 'Mojito', 4.3),
(3, 'Old Fashioned', 4.7),
(4, 'Martini', 4.4),
(5, 'Cosmopolitan', 4.2)
GO
ALTER INDEX drinkpk ON dbo.drink DISABLE
GO
SELECT * FROM dbo.Drink
GO
What is the result? See possible answers