可以做 select distinct table_name, column_name, data_type into #T1 from information_schema.columns, sysobjects where data_type like '%char' or data_type like'%text' and information_schema.columns.table_name = sysobjects.name and sysobjects.xtype = 'u' order by table_name, column_name 再用游标从#T1中读出表名何列名,分别从表中读取,估计这样一定慢的受不了
再用syscolumns表中的内容取到列名,再组织sql脚本,数据库一定会被累死。
还是查字端值中有“XXX”的表名称呢?
如果是前者,可以:
1‘XXX’很规范时,从sysobjects选取即可
2‘XXX’不规范时,可以建张表,专门存放表名称,从中取数据。
如果是后者,呵呵,用neosu(neo)的方法吧。
我就觉得不太可能,可是老板说是小CASE.头大了!!!neosu(neo)的方法理论上是可行的,但是实际上—————,
请问各位大侠,有没有现成的工具,可以实现上述功能???谢谢了!
>请问各位大侠,有没有现成的工具,可以实现上述功能???SQL SERVER的全文检索有没有试过?
select distinct table_name, column_name, data_type into #T1
from information_schema.columns, sysobjects
where data_type like '%char' or data_type like'%text'
and information_schema.columns.table_name = sysobjects.name
and sysobjects.xtype = 'u'
order by table_name, column_name
再用游标从#T1中读出表名何列名,分别从表中读取,估计这样一定慢的受不了
1、从sysobjects中取出所有库表的表名和ID
2、根据ID从syscolumns中取出与该表相关所有的字段名
3、根据表名和字段名组建一个sql
4、这肯定慢得要命,:)
select name from sysobjects where objectproperty(id,'IsUserTable') = 1 and name like '%xxx%'