Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Show only new IDs and then update table so that next time query is run they won't show

$
0
0

Hi as the title suggest I would like to run a query that only shows New ID's.

Here is some test data 

create table #tmpmerchant (Com_id int not null)

insert #tmpmerchant values ('1234')
insert #tmpmerchant values ('23456')
insert #tmpmerchant values ('74895')
insert #tmpmerchant values ('9578')
insert #tmpmerchant values ('9579')
insert #tmpmerchant values ('444889')

So the first time this runs it will return all records.

I then want to store these IDs in a permanent table.

When the query is next run it will only show new IDs that are not in the permanent table.

insert #tmpmerchant values ('1234')
insert #tmpmerchant values ('23456')
insert #tmpmerchant values ('74895')
insert #tmpmerchant values ('9578')
insert #tmpmerchant values ('9579')
insert #tmpmerchant values ('444889')
insert #tmpmerchant values ('54789')

So in this example '54789' will only show.

The permanent table is then updated with the '54789'

What would be the best way to achieve this?

Regards


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>