I need to automatically update a datetime field for a record to the current time whenever the record is updated.
create table t (
id bigint identity(1,1) not null primary key,
name varchar(50),
value varchar(50),
ts datetime not null default getutcdate()
)
go
insert t (name, value) values ('fred', 'bob')
go
update t set value='robert' where id=1 and name='fred'
go
One option would be to use an instead of update trigger.
create trigger update_t on t
instead of update as
update t set ts=getutcdate(),name=inserted.name, value=inserted.value from t inner join inserted on t.id=inserted.id
go
update t set value='dick' where id=1 and name='fred'
go
Sounds like I've solved my own problem, heh? Well, here's the catch ... you can't know the names of the other columns at the time you write the trigger. I.e. you only know that there is a ts field that needs to be updated internally, otherwise you want the update to do the same thing it would normally do.
Any ideas?...also, you don't know what database server it is going to be running on, so it has to be platform-independent.
...and it needs to be fully compatible with the Mayan calendar as well.
...oh yeah, and the final code must be a palindrome that reads the same way forwards as backwards! Yeah, that's it! What a kick-ass application design! Whooooo-eeeeeeee!sql
Showing posts with label updated. Show all posts
Showing posts with label updated. Show all posts
Thursday, March 22, 2012
Wednesday, March 7, 2012
Automate Cube Processing
Hello,
Can some one tell me how i could automatically
refresh the cube when the DW is updated, I know its
possible through DTS, can someone refer me to a site which
gives step by step details on how i could accompalish this?
Regards
ImranYou need to have analysis services installed on the machine that you will
run the DTS package from, there is a task called process cube that you can
then schedule
Ray Higdon MCSE, MCDBA, CCNA
--
"Imran" <anonymous@.discussions.microsoft.com> wrote in message
news:c78a01c40fcc$c8bef7c0$a001280a@.phx.gbl...
> Hello,
> Can some one tell me how i could automatically
> refresh the cube when the DW is updated, I know its
> possible through DTS, can someone refer me to a site which
> gives step by step details on how i could accompalish this?
> Regards
> Imran
Can some one tell me how i could automatically
refresh the cube when the DW is updated, I know its
possible through DTS, can someone refer me to a site which
gives step by step details on how i could accompalish this?
Regards
ImranYou need to have analysis services installed on the machine that you will
run the DTS package from, there is a task called process cube that you can
then schedule
Ray Higdon MCSE, MCDBA, CCNA
--
"Imran" <anonymous@.discussions.microsoft.com> wrote in message
news:c78a01c40fcc$c8bef7c0$a001280a@.phx.gbl...
> Hello,
> Can some one tell me how i could automatically
> refresh the cube when the DW is updated, I know its
> possible through DTS, can someone refer me to a site which
> gives step by step details on how i could accompalish this?
> Regards
> Imran
Labels:
automate,
automaticallyrefresh,
cube,
database,
dts,
itspossible,
microsoft,
mysql,
oracle,
processing,
refer,
server,
sql,
updated
Thursday, February 16, 2012
Auto update a field with the current date/time
How can I set a column in a table to auto update the date and time everytime something in that row is updated or when the row is first added?
Thanks ahead for the help,
Jason
Check out BOL to see if the timestamp column can solve your requirements.|||I want to be able to query on this and my understanding of timestamp is that it doesn't actually store dates. Is this incorrect?|||That is correct. You can set the default value for a column to getdate() or getutcdate(). That takes care of the inserts (if the column isn't mentioned in the insert statement).
For the updates, you'll need to write an update trigger.
|||
jasonburrwc84:
I want to be able to query on this and my understanding of timestamp is that it doesn't actually store dates. Is this incorrect?
Trigger is covered in the thread below. Hope this helps.
http://forums.asp.net/thread/1071147.aspx
Sunday, February 12, 2012
auto insert fro date in database ..how?
how i make date field in database auto updated,some one told me to use '" Now "' in insert command, but it dos't work, i think it's for asp. regardsYou need to use either GetDate() to get the local machine date/time or GetUtcDate() to get the date time in UTC (GMT).|||You can set up a column with a default value of Getdate() and not worry about manually inserting a value into it, or even use the timestamp column.|||hey guy's thanks for information it's working good. now the getdate() for date, what alse i can use like getdate() to import information??
regards|||
regards|||
Please mark the post as answered and thank you for the appreciation !
Subscribe to:
Posts (Atom)