--切换数据库
use c2
go
--查询当前数据库表名
select [name] from sysObjects where xtype='U' and [name] <> 'dtproperties' order by[name]
--查询当前数据库所有用户视图
Select [name] From sysObjects Where xtype='V' And [name]<>'syssegments' And [name]<>'sysconstraints' Order By [name]
--获得指定表中所有的列和类型
Select
c.name As '列名',
t.name As '列类型'
From syscolumns c, systypes t, sysobjects o
Where c.xtype = t.xusertype
And c.id = o.id
And o.name='base_dict' --指定表名
Order By c.colorder
--获取当前数据库指定列名在那些表中 [ 在修改数据库中的某个字段,但这个字段又有关联其他表,用这种方式一幕了然就能看出哪张表用了我这个字段 ]
Select
m.name AS '表名',
c.name As '列名',
t.name As '列类型'
From syscolumns c, systypes t, sysobjects o , ( select [name] from sysObjects where xtype='U' and [name] <> 'dtproperties' ) m
Where c.xtype = t.xusertype
And c.id = o.id
And o.name =m.name
And c.name='product_id' --指定列名
Order By m.name
--获取当前数据库所有表列名和表类型
Select
m.name AS '表名',
c.name As '列名',
t.name As '列类型'
From syscolumns c, systypes t, sysobjects o , ( select [name] from sysObjects where xtype='U' and [name] <> 'dtproperties' ) m
Where c.xtype = t.xusertype
And c.id = o.id
And o.name =m.name
Order By m.name
use c2
go
--查询当前数据库表名
select [name] from sysObjects where xtype='U' and [name] <> 'dtproperties' order by[name]
--查询当前数据库所有用户视图
Select [name] From sysObjects Where xtype='V' And [name]<>'syssegments' And [name]<>'sysconstraints' Order By [name]
--获得指定表中所有的列和类型
Select
c.name As '列名',
t.name As '列类型'
From syscolumns c, systypes t, sysobjects o
Where c.xtype = t.xusertype
And c.id = o.id
And o.name='base_dict' --指定表名
Order By c.colorder
--获取当前数据库指定列名在那些表中 [ 在修改数据库中的某个字段,但这个字段又有关联其他表,用这种方式一幕了然就能看出哪张表用了我这个字段 ]
Select
m.name AS '表名',
c.name As '列名',
t.name As '列类型'
From syscolumns c, systypes t, sysobjects o , ( select [name] from sysObjects where xtype='U' and [name] <> 'dtproperties' ) m
Where c.xtype = t.xusertype
And c.id = o.id
And o.name =m.name
And c.name='product_id' --指定列名
Order By m.name
--获取当前数据库所有表列名和表类型
Select
m.name AS '表名',
c.name As '列名',
t.name As '列类型'
From syscolumns c, systypes t, sysobjects o , ( select [name] from sysObjects where xtype='U' and [name] <> 'dtproperties' ) m
Where c.xtype = t.xusertype
And c.id = o.id
And o.name =m.name
Order By m.name