I've created a stored procedure in my example database on Azure:
CREATE PROCEDURE SalesLT.InsertOrderHeader(@OrderDate AS DATETIME=NULL, @DueDate AS DATETIME=NULL, @CustomerID AS INT=NULL)
AS
DECLARE @SalesOrderID INT = NEXT VALUE FOR SalesLT.SalesOrderNumber
IF @OrderDate IS NULL
BEGIN
SET @OrderDate = GETDATE()
END
INSERT INTO SalesLT.SalesOrderHeader(SalesOrderID,OrderDate,DueDate,CustomerID,ShipMethod)
VALUES (@SalesOrderID,@OrderDate,@DueDate,@CustomerID,'CARGO TRANSPORT 5')
PRINT @SalesOrderID
This created fine but when I tried to call it I wanted a date a week from now:
EXEC SalesLT.InsertOrderHeader @DueDate= DATEADD(dd,7,getDate()) , @CustomerID=1
This didn't work. The errors say that where it says 'dd' it was expecting ( or select, and the same for the closing bracket of get date. What's wrong with it?