模糊查詢(儲存過程)

2021-04-30 19:51:09 字數 1095 閱讀 7739

set ansi_nulls on

set quoted_identifier on

goalter procedure [dbo].[searchvague]

(@description varchar(1000),

@descriptionlength int,

@pagenumber tinyint,

@productsperpage tinyint,

@howmanyresults smallint output)as

/*create the table variable that will contain the search results*/

declare @products table

(rownumber smallint identity(1,1) not null,

productid int,

name varchar(50),

description varchar(1000),

price money,

image1filename varchar(50),

image2filename varchar(50)

)insert into @products

select productid,name,substring(description,1,@descriptionlength)+'...' as description,

price,image1filename,image2filename

from product

select  productid,name,substring(description,1,@descriptionlength)+'...' as description,

price,image1filename,image2filename

from @products

where name like '%'+@description+'%'

and rownumber between (@pagenumber-1)*@productsperpage+1

and @pagenumber*@productsperpage

oracle 儲存過程模糊查詢

t sql的寫法 useadventureworks gocreate procedure findemployee emplname varchar 20 asselect emplname rtrim emplname select c.firstname,c.lastname,a.city f...

儲存過程實現模糊查詢分頁

if exists select 1 from sysobjects where name getnewscount and type p drop proc getnewscount gocreate procedure getnewscount title nvarchar asselect c...

儲存過程實現模糊查詢問題

環境sql server 2008 查詢器 create proc lyf a hto nvarchar 50 null asselect ordponumer from orderline like n hto go執行 exec lyf a 洛陽 查詢字段結果很多?的資訊 我用查詢語句測試 se...