展开全部
用Sql语句查询指定表62616964757a686964616fe4b893e5b19e31333363373833格中指定字段的数据类型
一、语句通过systypes,syscolumns,sysobjects,三个系统表格联合检索获取结果。
systypes:数据库支持的数据类型属性。
syscolumns:数据库中各表格结构属性。
sysobjects:数据库中所有对象的属性。
二、检索语句演示
1、示例表格:base_zwb
2、语句如下:select name from systypes where
xtype in (select xtype from syscolumns where name = 'zw_mc' and
id in (select ID from sysobjects where name = 'base_zwb'));
语句解析:
1):select ID from sysobjects where name = 'base_zwb'),从表格‘sysobjects ’中,获取表格'base_zwb'的对象ID
2):select xtype from syscolumns where name = 'zw_mc' and id in (select ID from sysobjects where name = 'base_zwb'),以字段名称‘zw_mc’和第1步中获取的‘ID’,从表格‘syscolumns ’中获取数据类型的编号'xtype'
3):以第2部获取的 'xtype'编号,从表格‘systypes ’中获取数据类型。
结果如图: