我有那个表情
SELECT sysobjects.name AS TableName,
c.name AS ColumnName,
st.name AS TypeName,
"Length"
= case st.name
when 'uniqueidentifier' then 'nvm'
when 'bit' then 'nvm'
when 'int' then 'nvm'
when 'image' then 'nvm'
when 'datetime' then 'nvm'
when 'xml' then 'nvm'
else (cast(c.length as varchar))
end,
case c.isnullable
when '0' then 'No'
when '1' then 'Yes' end AS 'Nullable'
FROM
dbo.syscolumns c WITH (NOLOCK)
INNER JOIN dbo.systypes st ON st.xusertype = c.xusertype
INNER JOIN dbo.sysobjects WITH (NOLOCK) ON sysobjects.id=c.id
WHERE sysobjects.type in ('U')
ORDER BY TableName
所以我得到这个输出:
ACCREDITED_PROGRAMS ID uniqueidentifier nvm No
ACCREDITED_PROGRAMS APPLICATION_FK uniqueidentifier nvm Yes
ACCREDITED_PROGRAMS LICENCED_PROGRAM_FK uniqueidentifier nvm Yes
问题是有两个相邻的列指示哪些表和字段引用 APPLICATION_FK、LICENCED_PROGRAM_FK 和其他 FK