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 2008 Forums
 Transact-SQL (2008)
 identify timeline rate changes

Author  Topic 

smisich
Starting Member

5 Posts

Posted - 2012-03-25 : 21:46:14
I have this problem,

we set rates as follows
effective date expiry date rate
1/1/2011 1/3/2011 0.10
2/3/2011 31/12/2099 0.20

then the user can amend the rates as follows

2/3/2011 10/10/2011 0.20
11/10/2011 31/12/2011 0.30
011/01/2012 31/12/2099 0.40


I need to identify the change that the user makes.

eg the query should return
Eff Date Exp Date Before After
11/10/2011 31/12/2011 0.20 0.30
11/10/2011 31/12/2011 0.20 0.40


Can an anyone help me with this query?






khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-03-25 : 22:48:04
you will need to use the trigger to track the changes into another audit trail table

you may refer to this
http://www.sqlteam.com/article/audit-triggers-for-sql-server


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

smisich
Starting Member

5 Posts

Posted - 2012-03-26 : 22:31:44
thanks for your reply but im not looking to add any triggers. I need a script.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-03-26 : 22:53:51
so you have the before / after information stored somewhere ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2012-03-27 : 01:19:50
How are you capturing the changes in the backend, a sproc, .net app or what. What you can do is
1. Save current values to a table variable and or temp table
2. After the insert capture the values that were inserted into an OUTPUT variable
3. dump the values from stept 1 and step 2 into your audit table



<><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page
   

- Advertisement -