SELECT * FROM
OPENQUERY([192.168.1.5],
'select a.name 表名,b.name 字段名,c.name 字段类型,c.length 字段长度
,case when b.isnullable=1 then 1 else 0 end 允许空,
case when exists(SELECT 1 FROM sysobjects where xtype=''PK'' and parent_obj=b.id and name in (
SELECT name FROM sysindexes WHERE indid in(
SELECT indid FROM sysindexkeys WHERE id = b.id AND colid=b.colid
))) then 1 else 0 end 主键
from ELP.dbo.sysobjects a,ELP.dbo.syscolumns b,ELP.dbo.systypes c
where a.id=b.id
and a.name=''T_Mカレンダー''
and b.xtype=c.xtype'
);
OPENQUERY([192.168.1.5],
'select a.name 表名,b.name 字段名,c.name 字段类型,c.length 字段长度
,case when b.isnullable=1 then 1 else 0 end 允许空,
case when exists(SELECT 1 FROM sysobjects where xtype=''PK'' and parent_obj=b.id and name in (
SELECT name FROM sysindexes WHERE indid in(
SELECT indid FROM sysindexkeys WHERE id = b.id AND colid=b.colid
))) then 1 else 0 end 主键
from ELP.dbo.sysobjects a,ELP.dbo.syscolumns b,ELP.dbo.systypes c
where a.id=b.id
and a.name=''T_Mカレンダー''
and b.xtype=c.xtype'
);