select * from sysobjects
where xtype = 'u'
and [id] > 0下面自己做个循环就可以了(查找你要的字符串)找到了以后将sysobjects 的 [name]字段内容放在临时表或者Print 出来
就可以了
where xtype = 'u'
and [id] > 0下面自己做个循环就可以了(查找你要的字符串)找到了以后将sysobjects 的 [name]字段内容放在临时表或者Print 出来
就可以了
解决方案 »
- 【求助】as的意思
- 请帮我优化一下这个存储过程,关于分割字符串的
- 关于行转列的问题
- 请问,怎么得到表中的所有字段的字段名,字段类型,长度,还有属性说明呀???
- 怎样将时间差转为hh:mm:ss格式?
- 我的SQL server服务总是自己就停止了,害的别人连接不上,请教各位这是为什么?
- 表空间?
- 奇怪的调用参数的存储过程?
- 如何在SQL server 中实现用户登陆立即触发存储过程,如何提高执行存储过程的权限!!!!!
- SQL SERVER中的一个触发器,新增可以触发,可删除却不可以,该怎么写?
- 这个sql有几种写法
- SQL SERVER客户端企业管理器启动后无法注册,查询分析器却能连上服务器,事件探查器也能和服务器连接
IF EXISTS (SELECT name FROM sysobjects WHERE name = 'searchname' AND type = 'P') DROP PROCEDURE searchnameGocreate procedure searchname @sname varchar(10)Asbegincreate table #TableList( tablename char(200), colname char(200)) declare @table varchar(200)declare @col varchar(200) set nocount ondeclare curTab scroll cursor for select name from sysobjects where xtype='u'open curTabfetch next from curTab into @tablewhile @@FETCH_STATUS=0begin declare curCol scroll cursor for select name from syscolumns where (xtype=175 or xtype=167) and (id in (select id from sysobjects where name=@table)) open curCol fetch next from curCol into @col while @@FETCH_STATUS=0 begin execute('insert into #TableList select '''+@table+''','''+@col+''' from '+@table+' where '+@col+'='''+@sname+'''') fetch next from curCol into @col end close curCol deallocate curCol fetch next from curTab into @tableendclose curTabdeallocate curTabset nocount offselect distinct * from #TableListdrop table #tablelist end
set @str='White' --要搜索的字符串declare @s varchar(8000)
declare tb cursor local for
select s='if exists(select 1 from ['+b.name+'] where ['+a.name+'] like ''%'+@str+'%'')
print ''所在的表及字段: ['+b.name+'].['+a.name+']'''
from syscolumns a join sysobjects b on a.id=b.id
where b.xtype='U' and a.status>=0
and a.xusertype in(175,239,231,167)
open tb
fetch next from tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch next from tb into @s
end
close tb
deallocate tb/*--测试结果所在的表及字段: [authors].[au_lname]--*/
可惜要用游标,麻烦