+ -
当前位置:首页 → 问答吧 → 存储过程

存储过程

时间:2011-08-10

来源:互联网

在表格中的一个标志值是 SQL SERVER 的触发器在更新表的时候执行
存储过程自动计算得到写入数据库的。
页面就读取数据库拿到这个值。

问题是我每次更新表值都自动计算得到。
应该怎样使得在手动输入值。不执行存储过程的自动计算。



1 2 3
a1 b1 c1
a2 b2 c2


第3列的值是存储过程计算得到,应该怎样修改
存储过程,使得可以在手动修改的时候不 自动计算。而是得到手动值

作者: codsoul   发布时间: 2011-08-10

类似海量分页的

你定义参数‘
直接向存储过程传参就ok了


create proc PageNum
@PageSize int, --每页显示条数
@PageIndex int, --当前是第几页
@totalRows int output, --总行数
@totalPages int output --总页数
as
declare @startId int
declare @endId int
set @startId = @PageSize*(@PageIndex-1)+1
set @endId = @startId+@PageSize-1
select @totalRows=COUNT(*) from Books
set @totalPages=@totalRows/@PageSize
if(@totalRows%@PageSize != 0) --如果总行数除每页显示数据量的值不等于0,则总页数得加1
begin
set @totalPages=@totalPages+1
end
declare @IndexTable table(Id int identity(1,1) ,nId int)
insert into @IndexTable select Id from Books
select * from @IndexTable as t ,Books as b where t.Id>=@startId and t.Id<=@endId and t.nId=b.Id
go
 
declare @tr int --总行数
declare @tp int --总页数
exec PageNum 4,2,@tr output ,@tp output//4,2这都是可变的
print '这是总页数'+convert(varchar,@tp) --数据转换
print @tr

作者: LMAOhuaNL   发布时间: 2011-08-11

热门下载

更多