CREATE PROCEDURE jt_process
@batchno char(10) AS
select @batchno=@batchno + '%'select * from process where batchno like @batchno
@batchno char(10) AS
select @batchno=@batchno + '%'select * from process where batchno like @batchno
这句话回出现溢出问题
CREATE PROCEDURE JT_PROCESS @BATCHNO char(10)
AS
SELECT * FROM PROCESS WHERE RTRIM(BATCHNO) LIKE @BATCHNO + '%'
还是没记录返回啊,真是怪,还请指点
declare @BATCHNO char(10)
set @BATCHNO=你要输入的值
SELECT * FROM PROCESS WHERE BATCHNO LIKE @BATCHNO + '%'
有数据的话,那么你的存储过程就是对的
如果你是要返回单个记录的话.要使用OUTPUT参数.
例如:
CREATE PROCEDURE jt_process
@batchno char(10),
@a char(10) output
AS
select @a=a from process where batchno like @batchno
return 如果你是想返回一条条记录的话,你可以使用游标来做.但使用游标的话,你一定要指定VARYING和OUTPUT参数,例:
create procedure procauthornames
@curauthornames cursor varying output
as
set @curauthornames=cursor for
select au_fname+''+au_lname
from authors
open @curauthornames
GO
假设你要在另一个存储过程中利用这游标的返回值,则在另外调用的存储过程中你要这样写:
declare @curauthors cursor
declare @vcharauthornames varchar(64)
exec procauthornames @curauthors output
fetch next from @curauthors into @vcharauthornames
while @@fetch_status=0
begin
print @vcharauthornames
fetch next from @curauthors into @vcharauthornames
end
close @curauthors
deallocate @curauthors
GO
以后方法并不一定就能解决你的问题,但是其使用方法值得借鉴,愿对你有所帮助;
@batchno char(10) AS
select @batchno= rtrim(@batchno) + '%'select * from process where batchno like @batchno
照你那样还是不行啊,还有没有其它什么办法啊,可以实现模糊查询
select * from process where batchno like '@batchno'
吧