SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
ALTER PROCEDURE dbo.gbat_getnum
@tablename varchar(40),
@colname varchar(40),
@condition varchar(40),
@condition_value varchar(40),
@phonenum varchar(40) output,
@phonepsw varchar(40) output,
@yydz varchar(40) output,
@book_name varchar(40) output,
@book_mail varchar(40) output
as
set nocount on
begin tran
declare @SQL nvarchar(4000)
set @sql='select top 1 @phonenum=phonenum ,@phonepsw=phonepsw ,@yydz=yydz, @book_name=book_name, @book_mail=book_mail from '+@tablename+' with(rowlock,readpast) where '+@condition+'='+@condition_value+' order by '+@colname+''
exec sp_executesql @sql
,N'@phonenum varchar(40) output,@phonepsw varchar(40) output,@yydz varchar(40) output,@book_name varchar(40) output,@book_mail varchar(40) output'
,@phonenum output,@phonepsw output,@yydz output,@book_name output,@book_mail output
set @sql='update '+@tablename+' set '+@colname+'='+@colname+'+1 where phonenum='''+@phonenum+''''
exec(@sql)
commit tran
return
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
上面的SELETE 返回1行记录 我使用top1 但是我如果像返回10行或者20行记录 应该怎么写?使用top 10好像不行哦~~
------解决方案--------------------
不是很恶心,而是很猥琐