测试我的第一个表值函数,我没有得到任何数据,即使 SELECT 工作。
不返回任何东西:
select * from GetMvtHistory('C1505 BLACK')
返回正确的数据:
select row_number() OVER (order by DocId) as Id, detailId, Quant, 0 as Cumul
FROM vwDetailsHist
WHERE refer = 'C1505 BLACK'
ORDER BY DocId;
TVF代码:
ALTER FUNCTION [dbo].[GetMvtHistory]
(@Ref char(10))
RETURNS @MvtHist table
(
Id int,
[DetailId] int NULL,
[Quant] int NULL,
[Cumul] int NULL
)
WITH EXEC AS CALLER
AS
BEGIN
INSERT into @MvtHist
select row_number() OVER (order by DocId) as Id, detailId, Quant, 0 as Cumul
FROM vwDetailsHist
WHERE refer = @Ref
ORDER BY DocId;
RETURN
我错过了什么??谢谢 !