Error converting data type nvarchar to datetime

Today I wrote a stored procedure that executes with the current time as a parameter to the stored procedure, causing a number of problems.

See the original notation
Error. SQL error
Startsyntax near ‘)’ because the function cannot be used as a parameter to the stored procedure. Modified to
In SQL, you assign the return value of the getDate () function to a variable, and then assign it to the stored procedure variable. This error is resolved.

      

USE [TransferLog]
GO

DECLARE	@return_value int,

        
EXEC	@return_value = [dbo].[SSISLog_InsertQCTransferLog]
        @StartDate = getdate(),
		@LogCategoryId = 2,
		@AffectRows = '',
		@QCLastModifiedDate = N'''',
		@ErrorMessage = N'',
		@MaxAuditLogId = '',
		@MaxAuditPropertyId = ''


SELECT	'Return Value' = @return_value
SELECT CONVERT(datetime, GETDATE(), 120) AS Date
GO
USE [TransferLog]
GO

DECLARE	@return_value int,
        @timee datetime=getdate()
        
EXEC	@return_value = [dbo].[SSISLog_InsertQCTransferLog]
        @StartDate = @timee,
		@LogCategoryId = 2,
		@AffectRows = '',
		@QCLastModifiedDate = N'',
		@ErrorMessage = N'''',
		@MaxAuditLogId = '',
		@MaxAuditPropertyId = ''

SELECT	'Return Value' = @return_value
select @timee
SELECT CONVERT(datetime, GETDATE(), 120) AS Date
GO

But there it is again
The Error converting Data type, nvarchar to datetime, always thought that the Error converting type is still the wrong thing to assign to @startDate. I get a lot of replies on the Internet that say CONVERT(datetime, GETDATE(), 120) conversion type
The type of @qclastModifiedDate is also datetime, but in
Error.sql, I gave it a value
@QCLastModifiedDate=N””

After changing @qclastModifiedDate =N “, the error is gone. The database QCLastModifiedDate was written to the default value ‘1900-01-01 00:00:00 00.000’.

Right at last. True. SQL is the correct script after modification. I really need to be careful


Read More: