全資料庫各表中查詢內容所在的字段位置

2021-04-22 09:32:24 字數 735 閱讀 3181

declare   @str   varchar(100)  

set   @str='ph'     --要搜尋的字串  

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

某資料庫中各表有哪些字段

詳細資訊參照 sql2005 sql code go 2005實現資料庫表字段屬性統計 2000裡的系統表sysproperties描述表不存在,2005裡用sys.extended properties檢視替代 select 表名 c.name,表說明 isnull f.value 列名 a.na...

SQL Server查詢資料庫表和資料庫字段

在sql server中查詢資料庫表和字段的方式可以有三種 方法一 查詢所有表 select from sys.tables 查詢所有列 select from sys.columns 查詢所有擴充套件屬性,我們在設計資料庫表和字段時寫的中文備註等資訊會儲存在這裡 select from sys.e...

資料庫中的查詢

案例1 查詢員工表的中前五行 select from employees limit 5 select from employees limit 0,5 案例2 查詢 員工表 的第11條到第20條 select from employees limit 10,10 案例3 查詢員工表的第15條到30...