| Author |
Topic |
|
Mahavirjadhav
Starting Member
18 Posts |
Posted - 2010-06-30 : 03:43:49
|
| Hi,I am new to Sql server. I am not able to present my question in perticular words. But I am trying to explain briefly.I want to update the Commision table at the end of day, as comision rates may be changes daily or within given time span of dates. So the table Commision should be automaticaly should be updated.Defination of Commision table is:comm float,from_date Datetime,Todate Datetime,status nvarchar(10)status are : 1. Archived ,2. Active, 3. Planned.Please help me.Mahavir |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-30 : 03:52:44
|
Which column(s) should be updated and on which condition? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Mahavirjadhav
Starting Member
18 Posts |
Posted - 2010-06-30 : 04:05:43
|
quote: Originally posted by Mahavirjadhav Hi,I am new to Sql server. I am not able to present my question in perticular words. But I am trying to explain briefly.I want to update the Commision table at the end of day, as comision rates may be changes daily or within given time span of dates. So the table Commision should be automaticaly should be updated.Defination of Commision table is:comm float,from_date Datetime,Todate Datetime,status nvarchar(10)status are : 1. Archived ,2. Active, 3. Planned.Please help me.Mahavir
Thank you for u r reply. I want to update comm field depending on date.Mahavir |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
|
|
Mahavirjadhav
Starting Member
18 Posts |
Posted - 2010-06-30 : 04:48:08
|
quote: Originally posted by webfred Sorry but your question is still not clear to me.Please read this:http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx No, you're never too old to Yak'n'Roll if you're too young to die.
I am really sorry I want to change the status field. I am having values in tablecomm from to status10.0 10/5/2010 9/6/2010 Archive10.5 10/6/2010 9/7/2010 Active9.5 10/7/2010 9/8/2010 Plannedchange the status according to current date.Mahavir |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-30 : 05:20:51
|
Test this please:update Commisionset status = CASE WHEN dateadd(d,datediff(d,0,getdate()),0) > to_date then 'Archive' WHEN dateadd(d,datediff(d,0,getdate()),0) < from_date then 'Planned' ELSE 'Active' END Maybe there is a chance for a WHERE clause to exclude very old records from updates? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Mahavirjadhav
Starting Member
18 Posts |
Posted - 2010-06-30 : 05:45:45
|
quote: Originally posted by webfred Test this please:update Commisionset status = CASE WHEN dateadd(d,datediff(d,0,getdate()),0) > to_date then 'Archive' WHEN dateadd(d,datediff(d,0,getdate()),0) < from_date then 'Planned' ELSE 'Active' END Maybe there is a chance for a WHERE clause to exclude very old records from updates? No, you're never too old to Yak'n'Roll if you're too young to die.
Thank you for your reply problem is resolved.Mahavir |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-30 : 05:48:52
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|