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
 Script to identify a change/addition of a record

Author  Topic 

pisces113
Starting Member

5 Posts

Posted - 2010-11-01 : 07:16:29
Hi there,
This is my first posting.
I have a main table and there is a DTS job which imports a table of records. There may be new records and updates in this table so I need to do the following:
1.Add the new records and send in an email details of the new records added (new records are identified if there is no match in a ref number on the main table)
2. Show changes in records and email the details of the record before the change and after the change. Again the match will be on a ref number in the main table. Changes that I will be comparing would be on firstname field and phone number field.

The structure of my main table and the imported table will be the same.

Thanks in advance.

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-11-01 : 07:27:03
What is your question ?

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page

pisces113
Starting Member

5 Posts

Posted - 2010-11-01 : 08:52:48
How should I do this? There seems to be a lot involved; should I use triggers? how about the send mail, where will I code this? what should I use to check for change of/insertion of records?
Any pointers or some psedocode as to the steps to take.
TIA
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-01 : 11:54:32
1. use dts transform data task and send mail task
2. you can use trigger for this and use contents from INSERTED and DELETED tables inside

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

pisces113
Starting Member

5 Posts

Posted - 2010-11-01 : 12:04:56
I can do all of this via the DTS job in the steps or do I need to write code especially for the change in data how will I achieve this?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-01 : 12:09:39
are both the tables in same db in same server or different dbs in same server or different servers altogether?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

pisces113
Starting Member

5 Posts

Posted - 2010-11-01 : 12:51:50
Same server, same catalog. just different db names.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-01 : 12:54:05
then you can just use t-sql query itself.



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

pisces113
Starting Member

5 Posts

Posted - 2010-11-01 : 14:30:30
for every thing? send mail, triggers, comparison? i really don't know where to start any useful help to get me going would be good.
Go to Top of Page
   

- Advertisement -