/* 編寫儲存過程,查詢未加密的儲存過程指令碼文字
if exists(select name from sys.sysobjects where xtype='p' and name='proce_text')
drop procedure proce_text
gocreate procedure proce_text
ascreate table #procedure_detail(id int identity(1,1),texts nvarchar(max))
---使用游標,遍歷所有未加密儲存過程
declare @sql varchar(8000),@var varchar(1000)
set @sql=''
declare @name varchar(30)
set @name=''
declare cur1 cursor for
select distinct a.name from sys.sysobjects a,sys.syscomments b
where a.id=b.id and a.xtype='p' and b.encrypted=0
open cur1
fetch next from cur1 into @name
while @@fetch_status=0
begin
create table #1(a varchar(3000))
insert into #1(a) exec sp_helptext @name
declare cur2 cursor for
select a from #1
open cur2
fetch next from cur2 into @var
while @@fetch_status=0
begin
set @sql=@sql+' '+@var
fetch next from cur2 into @var
endclose cur2
deallocate cur2
drop table #1
insert #procedure_detail(texts) select @sql
set @name=''
set @sql=''
fetch next from cur1 into @name
end
close cur1
deallocate cur1
select * from #procedure_detail
--查詢結果
exec proce_text
shell中使用SQL實現查詢
先把文字進行格式處理,然後以空格為分隔符,取第二個空格後的字串,排序,去重,再降序排列,取前5個 arr cat 0100055f detail.txt sed e d awk f sort uniq c sort nr head 5 awk len 獲取陣列長度 for i 0 i len i d...
儲存過程系列之儲存過程sql查詢儲存過程的使用
1.查詢某個表被哪些儲存過程 以下簡稱 sp 使用到 select distinct object name id from syscomments where id in select object id from sys.objects where type p and text like ta...
儲存過程系列之儲存過程sql查詢儲存過程的使用
1.查詢某個表被哪些儲存過程 以下簡稱 sp 使用到 select distinct object name id from syscomments where id in select object id from sys.objects where type p and text like ta...