Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Rudimentary SQL ?

Author  Topic 

lewiska
Starting Member

1 Post

Posted - 2002-12-17 : 09:19:49
When I try to run the following command

INSERT INTO Unmatched_Debits
(File_Date, Cheque_Number, Amount)
SELECT Txn_Date, Cheque_Number, Amount
FROM Imported_Txns
WHERE ((SELECT Str(Cheque_Number & Amount)
FROM Imported_Txns
WHERE Txn_Date = '14/11/2002') NOT IN
(SELECT Str(Cheque_Number & Amount)
FROM Credits
WHERE Status = 'Unpaid'))

SQL Server tells me "Invalid operator for data type. Operator equals boolean AND, data type equals numeric."

I've searched through Books Online to no avail. Is my SQL statement invalid?

Nazim
A custom title

1408 Posts

Posted - 2002-12-17 : 09:45:53
if you are trying to concatenate cheque_number and amount .then you should use + instead of & .

Try this


INSERT INTO Unmatched_Debits
(File_Date, Cheque_Number, Amount)
SELECT Txn_Date, Cheque_Number, Amount
FROM Imported_Txns
WHERE ( Txn_Date = '14/11/2002') and (Str(Cheque_Number) & str(Amount) )
NOT IN
(SELECT Str(Cheque_Number) & str(Amount)
FROM Credits where status='Unpaid')



-------------------------
What lies behind you and what lies ahead of you are small matters compared to what lies within you.-Ralph Waldo Emerson


Edited by - Nazim on 12/17/2002 09:46:48

Edited by - Nazim on 12/17/2002 09:47:56
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-12-17 : 09:46:07
Just a guess. If you provide DDL, Sample Data and some expected results we can be exact.

INSERT INTO Unmatched_Debits (File_Date, Cheque_Number, Amount)
SELECT A.Txn_Date, A.Cheque_Number, A.Amount
FROM Imported_Txns A LEFT JOIN Credits B ON A.Cheque_Number = B.ChequeNumber
WHERE A.Txn_Date = '14/11/2002' AND B.Status <> 'Unpaid'




Go to Top of Page
   

- Advertisement -