I have two SQL tables on SQL Server 2008 :
GameData
GameID PK
GameReleaseDate
GameTitle
GameCoverClobID FK
GameClob
GameCoverClobID PK
Filename
So over time the covers are updated and whatnot, and as a result, I have several items in GameClob that have no matching ID in GameData are now effectively redundant data. I’d like to be able to delete these items, however I was wondering is there a SQL query that I can run, that will just show me the rows in GameClob that have no GameCoverClobID in the GameData table.
I hope I have explained this correctly, any questions, please ask.
Appreciate it!
Using the
WHERE NOT EXISTSclause should be faster thanLEFT JOINandNOT INbecause it shortcuts when the first record is found.To prevent this problem in the future it is best to create a foreign key between the 2 tables