主頁 > 知識(shí)庫 > 模糊查詢的通用存儲(chǔ)過程

模糊查詢的通用存儲(chǔ)過程

熱門標(biāo)簽:鐵路電話系統(tǒng) 百度競價(jià)排名 地方門戶網(wǎng)站 AI電銷 Linux服務(wù)器 呼叫中心市場需求 服務(wù)外包 網(wǎng)站排名優(yōu)化
復(fù)制代碼 代碼如下:

IF Exists(Select 1 From sysobjects Where Name='sp_search' And xType='P')
Drop Procedure sp_search
go
/*
模糊查詢的通用存儲(chǔ)過程
create by sxm,date 2009-7-14
參數(shù):
@table_name 表名
@condition 條件
*/
create proc sp_search(@table_name varchar(200),@condition varchar(100))
with encryption
as
begin
declare @strsql varchar(8000)
declare @col_name varchar(100)
declare @str_cols varchar(8000)
set @str_cols=''
--查詢表中的列名
declare cur_1 cursor for select column_name from information_schema.columns where table_name=@table_name
open cur_1
fetch cur_1 into @col_name
while @@fetch_status=0
begin
--組合查詢條件
set @str_cols=@str_cols + @col_name+' like ''%' + @condition+ '%''' + ' or '
fetch cur_1 into @col_name
end --while
close cur_1
deallocate cur_1
set @str_cols=left(@str_cols,len(@str_cols)-3)
--print @str_cols
set @strsql='select * from '+@table_name+' where '+ @str_cols
exec(@strsql)
end


您可能感興趣的文章:
  • 有關(guān)SQL模糊查詢
  • asp.net 多字段模糊查詢代碼
  • sqlserver 模糊查詢常用方法
  • mysql中模糊查詢的四種用法介紹
  • C語言按關(guān)鍵字搜索文件夾中文件的方法
  • C語言之字符串模糊查詢方法的實(shí)現(xiàn)

標(biāo)簽:衡水 黃山 蘭州 銅川 崇左 仙桃 湖南 湘潭

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《模糊查詢的通用存儲(chǔ)過程》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266