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
 General SQL Server Forums
 New to SQL Server Programming
 Comparing Two tables

Author  Topic 

korssane
Posting Yak Master

104 Posts

Posted - 2009-03-25 : 10:40:19
HI All,
i am completely stuck on this.
I have a daily table created and i want to compare it with the previous one. If any records added or removed ..this should be thrown to a 3rd table.
Is this possible and how..
Any suggestion will be greatly appreciated.
thanks

heavymind
Posting Yak Master

115 Posts

Posted - 2009-03-25 : 10:49:36
look at this article
http://db-staff.com/index.php/microsoft-sql-server/82-universal-method-work-with-sets

Thanks, Vadym
MCITP DBA 2005/2008
Chief DBA at http://www.db-staff.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-25 : 12:46:28
quote:
Originally posted by korssane

HI All,
i am completely stuck on this.
I have a daily table created and i want to compare it with the previous one. If any records added or removed ..this should be thrown to a 3rd table.
Is this possible and how..
Any suggestion will be greatly appreciated.
thanks


does your daily table have audit column like datecreated,datemodified etc?
Go to Top of Page

korssane
Posting Yak Master

104 Posts

Posted - 2009-03-25 : 13:54:08
Hi all,

thanks for your quick replies.
Yes the table has the 1st raw :01 20090325030201 1 that includes the date.


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-25 : 14:04:40
quote:
Originally posted by korssane

Hi all,

thanks for your quick replies.
Yes the table has the 1st raw :01 20090325030201 1 that includes the date.





then what you can do is to compare date value of this table to previous days table date value to capture the records that got changed since last day and then put it into third table.
Go to Top of Page

korssane
Posting Yak Master

104 Posts

Posted - 2009-03-25 : 14:47:29
thanks Visakh,
therer is not field called dat & time. the only information regarding the date is the file header.
is it possible to help me coding this ?
thanks
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-03-26 : 08:35:30
u can also use EXCEPT statement if u r working in SQL server 2005.. to get the difference of the tables....
if the structure of both tables are same?


Thanks...
Go to Top of Page

korssane
Posting Yak Master

104 Posts

Posted - 2009-03-26 : 11:05:37
thanks for the tips. i wil try this and get back to you.
Go to Top of Page

Itamar
Starting Member

19 Posts

Posted - 2009-03-26 : 11:30:51
quote:
Originally posted by korssane

HI All,
i am completely stuck on this.
I have a daily table created and i want to compare it with the previous one. If any records added or removed ..this should be thrown to a 3rd table.
Is this possible and how..
Any suggestion will be greatly appreciated.
thanks


hi there,
if this is sometihng you wanna do every now and then -you cab use the profiler. [url]http://nobhillsoft.com/Freebies.aspx[/url]

if you want a programmatic solution, try something like:
[url]http://www.sqlpass.org/Default.aspx?TabId=78&articleType=ArticleView&articleId=13[/url]

Nob Hill Software - Tools for Database People
SQL Version Control, Database Compare, Query Tools and more. www.nobhillsoft.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-28 : 03:58:27
quote:
Originally posted by korssane

thanks Visakh,
therer is not field called dat & time. the only information regarding the date is the file header.
is it possible to help me coding this ?
thanks



you can then extract date value from header and use it for the comparison
Go to Top of Page
   

- Advertisement -