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
 Update based on Another Record

Author  Topic 

stevieb
Starting Member

13 Posts

Posted - 2014-03-13 : 01:54:57
We are developing a database in SQL and we are trialing some of our typical analysis undertaken on out dataset.

I have a problem with a update function. ID direction Holiday Lat Long Speed obstime - Datestamp LicenseID - varchar(7) status - int (0 or 1) O-Unoccipied, 1-occupied Pickup - Boolean Dropoff - Boolean

I am trying to update the 'Pickup' or 'Dropoff' when the status changes from 0 to 1 or from 1 to 0 if the difference in the datestamp is less than 2 minutes. Pickup is when the status goes from 0 to 1 Drop off is when the status goes from 1 to 0

Thanks

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2014-03-13 : 08:07:26
More sounds like encoded narrative .. :) can you decode it by providing sample data (in form or insert statement) and the desired output? This would help us to utilize the given data and develop a query which would give you the desired output!

Cheers
MIK
Go to Top of Page

Robowski
Posting Yak Master

101 Posts

Posted - 2014-03-14 : 08:55:57
As MIK said, some sample data will always help but it sounds like you need a TRIGGER.

http://msdn.microsoft.com/en-us/library/ms189799.aspx
Go to Top of Page
   

- Advertisement -