SQL常用的小方法

1、--- 取得与表名相关的存储过程、方法、函数
selecT A.* from sysobjects A, syscomments B where a.id= B.id and b.text like '%你的表名%'
--------一定要like '%..%' 这样 要不查询不出任何东西来

2--取得一个表的所有的字段名(下面两个的效果是一样的)
select name from syscolumns where id=object_id('表名')
select name from syscolumns where id in (select id from sysobjects where type = 'u' and name = '表名')
3---查询当前数据库的所有的存储过程名
select name as 存储过程名称 from sysobjects where xtype='P'
4--查询一个表的所有的字段的类型,定义
select * from information_schema.columns where table_name = '表名'




posted on 2012-02-06 11:53  long6  阅读(202)  评论(0)    收藏  举报

导航