I just created a stored procedure to insert data into a table after performing some calculations. My create procedure code is below:
ALTER PROCEDURE [dbo].[myStoredProc]
@log_id INT,
@job_nm VARCHAR(20),
@feed_in_out_ind CHAR(1) = null,
@process_dt DATETIME = null,
@procedure_dt DATETIME = NULL,
@procedure_nm VARCHAR(20),
@object_ty VARCHAR(20),
@operation_ty VARCHAR(20),
@num_records INT,
@success_status BIT,
@error_msg VARCHAR(50) = NULL,
@start_time DATETIME,
@end_time DATETIME = null
AS
When I try to call the stored proc, if I use the GETDATE() for any of the datetimes, I get a syntax error Incorrect syntax near ')' When I replace the GETDATE() with an actual datetime, the procedure runs correctly.
Here is my calling code:
EXEC myStoredProc
@log_id = 1,
@job_nm = 'It',
@feed_in_out_ind = 'i',
@process_dt = GETDATE(),
@procedure_dt = GETDATE(),
@procedure_nm = 'Test 1',
@object_ty = 'test',
@operation_ty = 'test',
@num_records = 50,
@success_status = 0,
@error_msg = 'Hello',
@start_time = GETDATE(),
@end_time = GETDATE()
Any ideas? Thanks.
Try
DECLARE @Now AS DATETIME
SET @Now = GETDATE()
EXEC myStoredProc
@log_id = 1,
@job_nm = 'It',
@feed_in_out_ind = 'i',
@process_dt = @Now ,
@procedure_dt = @Now ,
@procedure_nm = 'Test 1',
@object_ty = 'test',
@operation_ty = 'test',
@num_records = 50,
@success_status = 0,
@error_msg = 'Hello',
@start_time = @Now ,
@end_time = @Now
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With