Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I would like to create an SPROC that will select all the items from Table A that are not in Table B. How can I do this?Thank youRobert
tkizer
Almighty SQL Goddess
38200 Posts
Posted - 2005-08-30 : 14:57:29
Here you go:
CREATE TABLE t1 (Column1 int NOT NULL)CREATE TABLE t2 (Column1 int NOT NULL)INSERT INTO t1 VALUES(1)INSERT INTO t1 VALUES(2)INSERT INTO t1 VALUES(3)INSERT INTO t2 VALUES(1)INSERT INTO t2 VALUES(2)SELECT t1.Column1 AS T1COLUMN1FROM t1LEFT OUTER JOIN t2ON t1.Column1 = t2.Column1WHERE t2.Column1 IS NULLDROP TABLE t1, t2
Wrapping the SELECT in a stored procedure should be trivial.Tara