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)
 Another question -- data integrity

Author  Topic 

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2002-02-28 : 23:26:17

I am tuning a poorly designed database that was put into production with no constraints. I have tables that need constraints however when I put them on they error out becuase there is invalid data.

I am wondering how to write a query that will accomplish the following.

All the messageFromID's that are in TBLMESSAGE and are not in TBLUSERDETAILS I would like to delete.

Cheers Guys thx again

TBLMESSAGE TBLUSERDETAILS

MessageFromID UserID



Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-03-01 : 00:18:36
How about


Delete From TBLMessage

WHERE

UserID NOT IN (Select UserID FROM TBLUserDetails)





Damian
Go to Top of Page

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2002-03-01 : 00:47:52
thx

Go to Top of Page
   

- Advertisement -