我有以下代码:
insert into @Precalculo (descripcion, Valor)
exec dbo.GetRankingTotalizador
@Fecha,
DateAdd(minute, (-1), DateAdd(day, 1, @Fecha)),
@cadenas,
@familias
insert into PrecalculoComparativaSemanal
select @Fecha, @cadenas, @familias, [1], [2], [3], [4] FROM
(select Descripcion, Valor from @Precalculo) p
PIVOT (min(Valor) FOR Valor in ([1], [2], [3], [4])) as pvt
它给我一个错误:
最佳答案
首先,您不能将表达式用作存储过程的参数。尝试:
DECLARE @d DATETIME;
SET @d = DateAdd(minute, (-1), DateAdd(day, 1, @Fecha));
insert into @Precalculo (descripcion, Valor)
exec dbo.GetRankingTotalizador @Fecha, @d, @cadenas, @familias;
接下来,根据您的SQL Server版本,@ table变量并不总是
INSERT/EXEC
的有效目标。我忘记了何时使之有效,但是您可能需要使用#temp表。最后,我强烈建议:
insert into PrecalculoComparativaSemanal (missing, column, list)
关于sql - 将表达式传递给存储过程时, 'minute'附近的语法不正确,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11632831/