select * from sysforeignkeys获取表外键
SELECT *FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME='T_GOODPRICE'获取主键,最简便的句子
SELECT name FROM SysColumns WHERE id=Object_Id('表名') and colid in (select keyno from sysindexkeys where id=Object_Id('表名'))获取主键,较简便的句子
今天奋战一天,就为了找这两个句子,其他的太麻烦了,就不写了