这是网上收的列子的应用:
select a.name as [column],b.name as type
from syscolumns a,systypes b
where a.id=object_id('dbo.HR_Employee') and a.xtype=b.xtype and a.name='EE_EmpNo'dbo.HR_Employee(表名) EE_EmpNo(列名) 结果:
column type
EE_EmpNo nvarchar
EE_EmpNo sysname但是表中实际字段只有 EE_EmpNo nvarchar 请问另一条语句是来自哪,还有望大虾解读一下上面代码的意思!如果我只想去当前表中有的字段那个改怎么写?望高手点拨下,先谢了...
select a.name as [column],b.name as type
from syscolumns a,systypes b
where a.id=object_id('dbo.HR_Employee') and a.xtype=b.xtype and a.name='EE_EmpNo'dbo.HR_Employee(表名) EE_EmpNo(列名) 结果:
column type
EE_EmpNo nvarchar
EE_EmpNo sysname但是表中实际字段只有 EE_EmpNo nvarchar 请问另一条语句是来自哪,还有望大虾解读一下上面代码的意思!如果我只想去当前表中有的字段那个改怎么写?望高手点拨下,先谢了...
from syscolumns a,systypes b
where a.id=object_id('dbo.HR_Employee') and a.xtype=b.xtype and a.name='EE_EmpNo'
and a.xtype='u'
就比如,主表
id col
1 'aaa'
从表
id,col2
1,'fsd'
1,'vew'
用id连接查询不就是两条记录嘛.
select a.name as [column],b.name as type
from syscolumns a,systypes b
where a.id=object_id('tb') and a.xusertype=b.xusertype and a.name='column'
TRY
执行一下这个:
select xtype,count(*) from systypes group by xtype having count(*)>1
你就知道了.