Reputation: 2283
Is there any fast way to get rows that are excluded by a query. For instance I run:
select * from tblUsers where user_type = 3
I'm looking for a fast to get the rows that were excluded by this query.
I understand I can easily change the where clause, but some queries are very complex and take some time to change. With lots of large queries, this task can take very long to do by hand.
Upvotes: 1
Views: 152
Reputation: 4207
Dump the results of your super complex query into a temporary table.
ex.
create table #Temp
(
First varchar(50),
Last varchar(50)
)
go
select * from #Temp
then do a join off the original data to get what you are looking for.
Upvotes: 1
Reputation: 1168
select * from tblUsers
EXCEPT
select * from tblUsers where user_type = 3
Upvotes: 0
Reputation: 2565
For an actual exclusion, you could do:
select * from tblUsers
EXCEPT
select * from tblUsers where user_type = 3
But why not just do
select * from tblUsers where user_type <> 3
Upvotes: 0