Maybe I am having a moment of 'afternoon', but can anyone explain why I get
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near ')'.
When running
CREATE PROC DisplayDate
(@DateVar DATETIME)
AS
BEGIN
SELECT @DateVar
END
GO
EXEC DisplayDate GETDATE();
3条答案
按热度按时间92dk7w1h1#
You can't pass in a function call as an argument to your stored procedure. Instead use an intermediate variable:
3df52oht2#
As Mitch Wheat mentioned you can't pass a function.
If in your case you should pass in a precalculated value or GETDATE() - you can use default value. For example, modify your stored procedure:
And then try:
Remark: Here I supposed that NULL value is not in use for this parameter. If it is not your case - you can use another unused value, for example '1900-01-01 00:00:00.000'
pgvzfuti3#
the solution I found was to declare temp variables before executing and pass these into the execution line e.g.