SQL Server - GETUTCDATE()'语法不正确''

时间:2022-06-18 22:47:59

Simple question: why does the top statement work, but the bottom one fails with

简单的问题:为什么top语句有效,但最低语句失败了

'Incorrect syntax near ('

'语法不正确('

Code:

USE [Research]
GO

DECLARE @d datetime 
SELECT @d = GETUTCDATE()

DECLARE @return_value int

EXEC    @return_value = [MyApp].[DateStamp]
        @date = @d

SELECT  'Return Value' = @return_value

GO

This one fails:

这个失败了:

USE [Research]
GO 

DECLARE @return_value int

EXEC    @return_value = [MyApp].[DateStamp]
        @date = GETUTCDATE()

SELECT  'Return Value' = @return_value

GO

DateStamp is a proc that writes a bunch of stuff to a time dimension, like financial year, quarter etc.

DateStamp是一个将一堆东西写入时间维度的过程,如财务年度,季度等。

Thanks.

1 个解决方案

#1


3  

why does the top statement work, but the bottom one fails

为什么top语句有效,但最低语句失败

Assigning values to parameters in EXECUTE must be a value a variable or DEFAULT. GETUTCDATE() is an expression that needs to be evaluated.

在EXECUTE中为参数赋值必须是变量值或DEFAULT。 GETUTCDATE()是一个需要计算的表达式。

#1


3  

why does the top statement work, but the bottom one fails

为什么top语句有效,但最低语句失败

Assigning values to parameters in EXECUTE must be a value a variable or DEFAULT. GETUTCDATE() is an expression that needs to be evaluated.

在EXECUTE中为参数赋值必须是变量值或DEFAULT。 GETUTCDATE()是一个需要计算的表达式。