Last active
December 11, 2015 16:39
-
-
Save stim371/4629551 to your computer and use it in GitHub Desktop.
two different pseudo-code examples to try to better explain what I was trying to achieve.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE c SET | |
CreateDate = CASE WHEN UPDATE ([CreateDateUTC]) THEN dbo.ConvertUTCTimeToPacific(i.CreateDateUTC) | |
ELSE CreateDate | |
END, | |
CreateDateUTC = CASE WHEN UPDATE ([CreateDate]) THEN dbo.ConvertPacificTimeToUTC(i.CreateDate) | |
ELSE CreateDateUTC | |
END | |
FROM dbo.Calls AS c | |
JOIN INSERTED AS i | |
ON i.CallId = c.CallId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE c SET | |
IF UPDATE ([CreateDateUTC]) -- I'm not sure if this works, but do you need the case statement? (see note 1 below) | |
CreateDate = dbo.ConvertUTCTimeToPacific(i.CreateDateUTC) | |
IF UPDATE ([CreateDate]) | |
CreateDateUTC = dbo.ConvertPacificTimeToUTC(i.CreateDate) | |
FROM dbo.Calls AS c | |
JOIN INSERTED AS i | |
ON i.CallId = c.CallId; | |
/* Note 1 | |
Can't you conditionally set the value instead of always assigning it and switching whether it overwrites itself or gets converted? | |
*/ | |
/* Note 2 | |
This does not work | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment