在当前数据库的所有表,所有字段查找字符串
来源:互联网 发布:程序员的数学 统计 pdf 编辑:程序博客网 时间:2024/04/30 17:54
/*
search a string in all databaes tables and all fields
*/
if object_id('search_db') is not null
drop proc search_db
go
create proc search_db
@table nvarchar(100),
@cond nvarchar(512)
as
declare hCForEach cursor global for
select sqlstmt =
'if exists (' + stmt + ')
print ''' + replace(stmt, '''', '''''') + ''''
from(
select stmt='select * from [' + TABLE_NAME + '] where convert(nvarchar, [' + COLUMN_NAME + ']) like ''' + @cond + ''''
from INFORMATION_SCHEMA.COLUMNS A
where (IsNull(@table, '') = '' or TABLE_NAME like @table) and DATA_TYPE <> 'image' and
(SELECT TABLE_TYPE from INFORMATION_SCHEMA.TABLES B where A.TABLE_NAME = B.TABLE_NAME) = 'BASE TABLE'
) T
exec sp_msforeach_worker @command1 = N'?'
go
exec search_db '', '%HKG%'
drop proc search_db
search a string in all databaes tables and all fields
*/
if object_id('search_db') is not null
drop proc search_db
go
create proc search_db
@table nvarchar(100),
@cond nvarchar(512)
as
declare hCForEach cursor global for
select sqlstmt =
'if exists (' + stmt + ')
print ''' + replace(stmt, '''', '''''') + ''''
from(
select stmt='select * from [' + TABLE_NAME + '] where convert(nvarchar, [' + COLUMN_NAME + ']) like ''' + @cond + ''''
from INFORMATION_SCHEMA.COLUMNS A
where (IsNull(@table, '') = '' or TABLE_NAME like @table) and DATA_TYPE <> 'image' and
(SELECT TABLE_TYPE from INFORMATION_SCHEMA.TABLES B where A.TABLE_NAME = B.TABLE_NAME) = 'BASE TABLE'
) T
exec sp_msforeach_worker @command1 = N'?'
go
exec search_db '', '%HKG%'
drop proc search_db
- 在当前数据库的所有表,所有字段查找字符串
- 获取当前数据库(mysql)所有表的字段内容
- sql语句怎么在一个数据库中查找拥有同一字段名的所有表
- 查找整个数据库里面包含某一字段的所有表
- 查找数据库中含有某字段的所有表 --【叶子】
- 查找数据库中含有某字段的所有表
- Sqlserver 查找数据库中含有某字段的所有表
- 查找数据库中包含某个字段的所有表
- 查找数据库中含有某字段的所有表
- 查找数据库里所有表当前的最大id
- 字符串在所有程序里边的查找
- window查找指定字符串在当前目录下的所有文件中是否存在
- 在数据库中查找含有某列的所有表
- 查找当前用户的所有数据库对象的依赖关系
- 更新数据库所有表及所有字段的存储过程
- 统计数据库所有表的字段之和
- 比较两个数据库所有表的字段
- 获取数据库表的所有字段信息
- 20060510个人日志(vb程序打包安装问题)
- 今天开始写blog
- 毕业设计(二十一)-"自由支配百分之二十工作时间""Don't be evil""要自信"
- 核心竞争力
- Java做的开源搜索引擎
- 在当前数据库的所有表,所有字段查找字符串
- DBA的典型职责(你想做到合格DBA必须要做的事情)
- css中如何使div居中(垂直水平居中)
- 你为什么被骗-广交会摊位购买防骗篇
- 破解-SourceFormatX256cn
- 失恋金句
- http://www.connectionstrings.com/ 各种数据库连接的写法
- Listen to English - Learn English
- C++学习推荐书目