Original: SQL Drip 29-error everywhere
I just want to say that the following are very basic SQL knowledge, but it is easy to make mistakes. So open our eyes, hold our breath, check it carefully!
Case 1
If not EXISTS (select OrderID from Corpemailsendqueue where orderid=600643425)
Begin
EXEC sp3_corpemailsendqueue_i @ID =null, @OrderID =600643425, @OrderType = ' F ', @EmailType = '-2 ', @ResendTime =0, @SendTime =null, @CurrentStatus = ' u ', @GenerateTime =null
End
This is the final correct wording, it seems simple, but in some places it is easy to make mistakes.
Error 1
If not EXISTS select COUNT (1) from Corpemailsendqueue where orderid=600643425
Begin
EXEC sp3_corpemailsendqueue_i @ID =null, @OrderID =600643425, @OrderType = ' F ', @EmailType = '-2 ', @ResendTime =0, @SendTime =null, @CurrentStatus = ' u ', @GenerateTime =null
End
It seems to be OK, but it will be an error, the following errors:
MSG 156, Level A, State 1, line 1
Incorrect syntax near the keyword ' select '. You need to wrap the select COUNT (1) from Corpemailsendqueue where orderid=600643425 with the brackets.
Error 2
If not EXISTS (select COUNT (1) from Corpemailsendqueue where orderid=600643425)
Begin
EXEC sp3_corpemailsendqueue_i @ID =null, @OrderID =600643425, @OrderType = ' F ', @EmailType = '-2 ', @ResendTime =0, @SendTime =null, @CurrentStatus = ' u ', @GenerateTime =null
End
It doesn't seem to be a problem, but after replacing OrderID with Count (1), exists doesn't work, select COUNT (1) from Corpemailsendqueue where orderid=600643425 In any case there is value, I mean even 0 is exists, so the following stored procedure is not executed under any circumstances.
Case 2
Select DateDiff (hh, ' 2013-11-21 16:50 ', ' 2013-11-21 17:35 ') This gets the result is actually 1, I think SQL Server is not the convulsions, the two time difference between 45 minutes, less than 1 hours, Helpless can only use Select DateDiff (MI, ' 2013-11-21 16:50 ', ' 2013-11-21 17:35 ') to get the result is 45.
There is also a little knowledge, if you want to get the current time can be used getdate (), if it is UTC time, is the current time minus 8, you can use getUTCDate ().
SQL Drip 29-errors everywhere