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
 Updating table at perticular time daily

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.
Go to Top of Page

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
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-06-30 : 04:25:57
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.
Go to Top of Page

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 table
comm from to status
10.0 10/5/2010 9/6/2010 Archive
10.5 10/6/2010 9/7/2010 Active
9.5 10/7/2010 9/8/2010 Planned


change the status according to current date.


Mahavir
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-06-30 : 05:20:51
Test this please:

update Commision
set 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.
Go to Top of Page

Mahavirjadhav
Starting Member

18 Posts

Posted - 2010-06-30 : 05:45:45
quote:
Originally posted by webfred

Test this please:

update Commision
set 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
Go to Top of Page

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.
Go to Top of Page
   

- Advertisement -