August 12, 2008 at 5:16 am
Hello
Am using the following query:
And i get the following error message:
Msg 174, Level 15, State 1, Line 6
The isnull function requires 2 argument(s).
Msg 156, Level 15, State 1, Line 10
Incorrect syntax near the keyword 'THEN'.
Can anyone tell me why?
August 12, 2008 at 5:27 am
ISNULL requires two arguments;
ISNULL ( check_expression , replacement_value )
so to replace the value ISNULL as 0 use
ISNULL([T_ICPAudit.Amount],0)
August 12, 2008 at 5:42 am
Am still getting the same error message:
Msg 4145, Level 15, State 1, Line 5
An expression of non-boolean type specified in a context where a condition is expected, near 'ELSE'.
Msg 156, Level 15, State 1, Line 9
Incorrect syntax near the keyword 'THEN'.
August 12, 2008 at 6:33 am
IF is procedural statement.
SELECTCASE TransactionType
WHEN 'REFUND' THEN CAST(-Amount AS MONEY)
WHEN 'CHARGE' THEN CAST(Amount AS MONEY)
ELSE CAST(0 AS MONEY)
END AS [Amount],
TransactionType,
TransactionStatus,
TransactionResult,
ICPBatchNumber,
CONVERT(VARCHAR(11), RecordCreated, 106) AS [RecordCreated]
FROMCMDATA.dbo.T_ICPAudit
WHERETransactionResult = 'ACCEPTED'
AND RecordCreated >= '2006-06-23 00:00:01'
N 56°04'39.16"
E 12°55'05.25"
August 12, 2008 at 6:49 am
I ran it again and got the following:
Msg 8117, Level 16, State 1, Line 1
Operand data type nvarchar is invalid for minus operator.
seems its data type related
August 12, 2008 at 7:28 am
Fixed, incorrect placement of syntax, eventually used:
WHEN 'REFUND' THEN - CAST (Amount AS MONEY)
August 12, 2008 at 8:09 am
So the query work now?
N 56°04'39.16"
E 12°55'05.25"
August 12, 2008 at 8:49 am
Yeah, got one question for you though, what are the best and easily comprehensible books out there to understand T-SQL development?
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply