-- Collection of code snippets by Arne Vajhøj 
-- posted to eksperten.dk, usenet and other places (2002-now) 
CREATE TABLE tabel1 (
    id INTEGER NOT NULL PRIMARY KEY,
    name VARCHAR(32)
)
GO
CREATE TABLE tabel2 (
    id INTEGER NOT NULL PRIMARY KEY,
    name VARCHAR(32)
)
GO
INSERT INTO tabel1 VALUES(1, 'Bo')
GO
INSERT INTO tabel1 VALUES(2, 'Ib')
GO
INSERT INTO tabel1 VALUES(3, 'Per')
GO
INSERT INTO tabel1 VALUES(4, 'Kaj')
GO
INSERT INTO tabel2 VALUES(1, 'Ib')
GO
INSERT INTO tabel2 VALUES(2, 'Per')
GO
INSERT INTO tabel2 VALUES(3, 'Kaj')
GO
INSERT INTO tabel2 VALUES(4, 'Thor')
GO
SELECT * FROM tabel1 WHERE name NOT IN (SELECT name FROM tabel2)
GO
SELECT * FROM tabel1 WHERE NOT EXISTS (SELECT * FROM tabel2 WHERE tabel2.name = tabel1.name)
GO
