我在執行下面的查詢時遇到錯誤。我做錯了什麼?請幫我修正語法錯誤
Msg 512,Level 16,State 1,Line 3 子查詢返回的值超過1。當子查詢遵循=,!=,<,< =,>,> =或當子查詢用作表達式時,這是不允許的。
select
so.name 'Table Name'
,so.id 'Table ID'
,so.xtype
,sc.name 'Column Name'
,sc.id 'Column ID'
,sf.constid
,sf.fkeyid 'Object ID of the table with FOREIGN KEY'
,sf.rkeyid 'Referenced Table ID'
,(select o.name 'Referenced Table'
from sysforeignkeys f
inner join sysobjects o
on o.id=f.rkeyid
where o.xtype='U')
from sysobjects so
inner join syscolumns sc
on so.id=sc.id
inner join sysforeignkeys sf
on so.id=sf.fkeyid
where so.xtype='U'
and (sc.name like 'SSN'
OR sc.name LIKE 'ssn%'
OR sc.name LIKE 'ssn%'
OR sc.name LIKE '%_ssn%'
OR sc.name LIKE '_ocsecno'
OR sc.name LIKE 'Ssn%');
像=「SSN」要麼使用LIKE或=,既會造成概率 – 2015-03-31 18:09:14
標題可以改善 – rpax 2015-03-31 20:19:05