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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query Help

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2009-11-26 : 05:55:17
Dear All,

I have a 2 sql Server i need to find out the the invoice number which are present in one server and not in another server.

Here is the query

select distinct T1."snp_Invoice_Number" "c1"
from "AR_Snapshot" T1
where T1."snp_Post_Period_EOM" >= {ts '2006-01-31 00:00:00.000'}

I have the same schema in both the server.

please help me to write a query for this

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-11-26 : 07:20:02
is there any linked server bw the server

then u can do it

--1
select distinct T1.snp_Invoice_Number c1
from firstserver.schema.AR_Snapshot T1
left join secondserver.schema.AR_Snapshot T2 on t2.snp_Invoice_Number = t1.snp_Invoice_Number
where t2.snp_Invoice_Number null

----2
select *
from firstserver.schema.AR_Snapshot where snp_Invoice_Number not in
(select snp_Invoice_Number from secondserver.schema.AR_Snapshot)

--3
select *
from firstserver.schema.AR_Snapshot t where NOT EXISTS
(select * from secondserver.schema.AR_Snapshot WHERE snp_Invoice_Number = t.snp_Invoice_Number)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-27 : 02:30:40
quote:
Originally posted by gangadhara.ms

Dear All,

I have a 2 sql Server i need to find out the the invoice number which are present in one server and not in another server.

Here is the query

select distinct T1."snp_Invoice_Number" "c1"
from "AR_Snapshot" T1
where T1."snp_Post_Period_EOM" >= {ts '2006-01-31 00:00:00.000'}

I have the same schema in both the server.

please help me to write a query for this



you can use SSIS for this. what you need is this

http://www.sqlis.com/post/Get-all-from-Table-A-that-isnt-in-Table-B.aspx
Go to Top of Page
   

- Advertisement -