【发布时间】:2015-10-15 06:16:04
【问题描述】:
我正在尝试使用以下存储过程,但出现错误
消息 8115,级别 16,状态 2,过程 xlaAFSsp_reports,第 25 行
将表达式转换为数据类型 int 时出现算术溢出错误。第 24 行:将 myadapter 调暗为新的 SqlDataAdapter(mycommand)
第 25 行:mycommand.CommandType = CommandType.StoredProcedure
第 26 行:myadapter.fill(ds,"results")
第 27 行:
第 28 行:rs=ds.tables(0).rows(0)
表中的值不为 0
知道是什么原因造成的吗?
ALTER PROCEDURE [dbo].[xlaAFSsp_reports]
AS
SET NOCOUNT ON
-- Consolidate disk size (also done on xlaAFSsp_expire_files)
UPDATE xlaAFSstorages
SET currentsize = ISNULL((select SUM(filesize)
from xlaAFSfiles
where s3 = 0
and storageid = xlaAFSstorages.storageid), 0)
create table #ttable (
totalfiles int,
usedspace int,
nonexpiring int,
protected int,
totalusers int,
paidusers int,
totalstorages int,
allocatedspace int,
)
-- Total Stats
insert into #ttable (totalfiles, usedspace, nonexpiring, protected, totalusers, paidusers, totalstorages, allocatedspace)
values (0, 0, 0, 0, 0, 0, 0, 0)
update #ttable
set totalfiles = (Select count(fileid) from xlaAFSfiles),
usedspace = (Select isnull(sum(filesize), 0) from xlaAFSfiles),
nonexpiring = (Select count(fileid) from xlaAFSfiles
where fsid in (select fsid from xlaAFSfilesets
where expiredate = '-')),
protected = (Select count(fileid) from xlaAFSfiles
where fsid in (select fsid from xlaAFSfilesets
where accesspwd <> '')),
totalusers = (Select COUNT(userid) from xlaAFSusers),
paidusers = (Select COUNT(userid) from xlaAFSusers where ispaid <> ''),
totalstorages = (Select COUNT(storageid) from xlaAFSstorages),
allocatedspace = (Select isnull(SUM(allocatedsize),-1)
from xlaAFSstorages)
select * from #ttable
drop table #ttable
【问题讨论】:
标签: sql sql-server stored-procedures