Tình huống:
Làm cách nào để bạn tìm thấy tất cả các bảng trong Cơ sở dữ liệu SQL Server có Cột nhận dạng?Giải pháp:
Chúng ta có thể sử dụng các bảng hệ thống như sys.columns và sys.tables để lấy thông tin này.--Find out all the columns for all the tables on which Identity Property is enabled SELECT DB_Name() AS DatabaseName ,OBJECT_NAME(c.OBJECT_ID) AS TableName ,c.NAME AS ColumnName FROM YourDBName.sys.columns c INNER JOIN sys.tables t ON c.object_id = t.object_id WHERE is_identity = 1

Video Demo:Cách tìm tất cả các bảng có Cột nhận dạng trong SQL Server