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)
 Help with this?

Author  Topic 

TJ
Posting Yak Master

201 Posts

Posted - 2002-09-16 : 18:29:27
I posted a request for help earlier. Perhaps I needed to add more info or ask it a different way? I thought I'd try this to see if someone could help me with my quandry...

I have two tables: Efile & Dlrcodes

I have custnumbers in Efile that I need to populate the Dlrcodes table with. The criteria is that the custnumber does not already exist in the Dlrcodes table, and the Dlrcodes table has an 'N' in the column 'Assigned'. There is nothing in either table to help with the join. The second criteria is that while choosing custnumbers from the Efile table, the associated column called 'Dlrcode' must be null.

I'm using SQL 7.0.

I've searched through Transact SQL help, Teach Yourself Transact SQL in 21 days, Professional SQL Server 7.0, the forums located on this site and have not found anything to help me. I'm hoping you can!

Thanks!
Teresa



robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-09-16 : 18:39:08
Ummmmmmm...how about the full table structures for both tables, some sample data, and the desired output? And any SQL you currently have.

Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-09-16 : 19:09:56
If your looking for custnumbers that don't exist in dlrcodes table then how could the column 'Assigned' have an 'N'.

With this little issue aside try something like this.

INSERT INTO DlrCodes(custnumber)
SELECT A.custnumber
FROM EFile AS A LEFT JOIN Dlrcodes AS B ON A.custnumber = B.custnumber
WHERE B.custnumber IS NULL AND A.Dlrcode IS NULL

the best I can do without the table structures and some further clarification on the criteria.

Go to Top of Page

TJ
Posting Yak Master

201 Posts

Posted - 2002-09-16 : 20:04:46
Please forgive my impatience! I posted an earlier post re: Select & Update which I had not received a reply to. I thought it was because I'm not always clear in explaining what I'm doing or what I need help with.

I have no excuse... I just got carried away!

After I got home and checked the forum, I see that some of you were able to help me! I appreciate it! I promise to be more patient in the future... REALLY!

Humbly,
TJ
Go to Top of Page
   

- Advertisement -