從下麵2句SQL語句執行來看, SELECT * FROM sys.tables WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasPrimaryKey') <> 0 SELECT * FROM sys.tables WHERE OBJECTPROPERTY(OBJEC ...
從下麵2句SQL語句執行來看,
SELECT * FROM sys.tables WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasPrimaryKey') <> 0 SELECT * FROM sys.tables WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasForeignKey') <> 0View Code
就知道那一張表有主鍵PrimaryKey或ForeignKey。
比如,表[Q]和[QQ]既沒有主鍵,也沒有外鍵。
當在SQL語句的條件中,使用“=”,那說明查詢出來的結果是否,即是不包含主鍵或外鍵。
SELECT * FROM sys.tables WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasPrimaryKey') = 0 SELECT * FROM sys.tables WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasForeignKey') = 0View Code