Given the following T-SQL statement how do I (by inspection) determine the primary key? If it isn’t listed (like I suspect) what would it look like?
CREATE TABLE [dbo].[BLDGINFO](
[LBLDGRUNNO] [int] NULL,
[LBLDGNO] [int] NOT NULL,
[FBIVOLUME] [float] NULL,
[FBIACOND] [float] NULL,
[NBIHTYPE] [float] NULL,
[NBILTYPE] [float] NULL,
[NBISTORIES] [float] NULL,
[NBIFTYPE] [float] NULL,
[NBIBEDS] [float] NULL,
[NBIUNITS] [float] NULL,
[SBIRATENO] [nvarchar](31) NULL,
[NBICTYPE] [float] NULL,
[NBIYEARBLT] [int] NULL DEFAULT ((0)),
[NBITHBNDRY] [int] NULL
) ON [PRIMARY]
If a primary key has been defined at all, it will be
LBLDGNO. However, it is quite possible that there is no primary key defined at all. You can determine this as follows:This query will return all columns included in the primary key. If it returns an empty resultset, then there is no primary key defined.