如何查找数据库中某一字段值?并显示其所在的表名

lostwaterfish 2006-09-23 10:09:40
如题!!
...全文
265 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lostwaterfish 2006-09-25
  • 打赏
  • 举报
回复
想知道为什么呢!!大家帮帮
lostwaterfish 2006-09-23
  • 打赏
  • 举报
回复
我做过替换了,之后出现:
select * from SYS_PRIV_ALLOC where EFF_ALL = '长裤'
select * from SYS_PRIV_ALLOC where ROLE_ID = '长裤'
select * from SYS_PRIV_ALLOC where PRIV_ID = '长裤'
select * from SYS_PRSNL where PRSNL_NUM = '长裤'
select * from SYS_PRSNL where SURNAME = '长裤'
select * from SYS_PRSNL where GIVENNAME = '长裤'
select * from SYS_PRSNL where FULL_NAME = '长裤'
select * from SYS_PRSNL where INPUT_CODE = '长裤'
select * from SYS_PRSNL where GENDER = '长裤'
select * from SYS_PRSNL where ID_TYPE = '长裤'
select * from SYS_PRSNL where ID_NUM = '长裤'
select * from SYS_PRSNL where OFFICE_NUM = '长裤'


并无结果,万请赐教!!谢谢!
九斤半 2006-09-23
  • 打赏
  • 举报
回复
你在查询分析器里运行一下看看就知道了,

这段是查找包含字符串'kkkkkk'
lostwaterfish 2006-09-23
  • 打赏
  • 举报
回复
能描述下,如何查找么? 我是新手,谢谢!!
九斤半 2006-09-23
  • 打赏
  • 举报
回复
[ZT]查找数据库中包含某一字符的表(遍历表和字段)

DECLARE @table_name varchar(200),@col_name varchar(200)

declare tutest_1 cursor for

select a.name, c.name from sysobjects a
join sysindexes b on a.id=b.id
right join syscolumns c on c.id=b.id
--求字段的类型
join systypes d on d.xusertype=c.xusertype
where b.indid in (0,1)
and a.xtype='U'
and b.rows>100
and d.name like'%char%'


OPEN tutest_1

FETCH NEXT FROM tutest_1
INTO @table_name, @col_name

WHILE @@FETCH_STATUS = 0
begin
declare @sql varchar(8000)

set @sql=''


set @sql=+@sql+ 'select * from '+@table_name +' where '+ @col_name +' = ''kkkkkk'''

--exec(@sql)
-- 也可以把语句打出来
if @@rowcount>0
print(@sql)


FETCH NEXT FROM tutest_1 INTO @table_name, @col_name
end
CLOSE tutest_1
DEALLOCATE tutest_1
lostwaterfish 2006-09-23
  • 打赏
  • 举报
回复
忘记补充了,是在MS SQLSERVER2000中!

22,207

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧