gpt4 book ai didi

sql-server - SQL Server 中的记录计数

转载 作者:行者123 更新时间:2023-12-03 02:23:58 25 4
gpt4 key购买 nike

看看这个 SP。

ALTER PROCEDURE [dbo].[sp_GetRecTitleVeh] 

AS
BEGIN
select
a.StockNo, c.ClaimNo,
v.VIN, v.[Year],v.Make, v.Model,
c.DOAssign, t.DOLoss, t.RecTitleDate
From
dbo.Assignments a,
dbo.Assignment_ClaimInfo c,
dbo.Assignment_TitleInfo t,
dbo.Assignment_VehicleInfo v
Where
a.AssignmentID= c.AssignmentID and
c.AssignmentID= t.AssignmentID and
t.AssignmentID= v.AssignmentID and
t.RecTitleDate is not null and
c.InsuranceComp = 'XYZ' and
a.StockNo not in (select StockNo from dbo.Invoice where InvoiceType = 'Payment Invoice')
order by t.RecTitleDate
END

这个 SP 工作正常,并给了我所需的结果。

我需要问的是有没有最短的方法来计算执行这个SP获得的记录。对于前。我正在尝试这样

select count(*) from sp_GetRecTitleVeh

我知道有一个解决方案,例如 -

ALTER PROCEDURE [dbo].[sp_CountRecTitleVeh] 

AS
BEGIN
select
count(a.StockNo)
From
dbo.Assignments a,
dbo.Assignment_ClaimInfo c,
dbo.Assignment_TitleInfo t,
dbo.Assignment_VehicleInfo v
Where
a.AssignmentID= c.AssignmentID and
c.AssignmentID= t.AssignmentID and
t.AssignmentID= v.AssignmentID and
t.RecTitleDate is not null and
c.InsuranceComp = 'XYZ' and
a.StockNo not in (select StockNo from dbo.Invoice where InvoiceType = 'Payment Invoice')
order by t.RecTitleDate
END

你知道我如何计算通过执行 SP 获得的记录吗?

感谢您分享您的宝贵时间。

最佳答案

尝试...

EXEC sp_GetRecTitleVeh 
SELECT @@Rowcount

关于sql-server - SQL Server 中的记录计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2057110/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com