查看此SP。在SQL Server中計數記錄
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有記錄。
感謝您分享寶貴的時間。
請注意,這不是這個好主意。如果您在存儲過程中的選擇之後添加單個命令,則這將不起作用。 – 2010-01-13 14:28:08