I created Comment Converter as way to show people how much better answers are in answers than comments. It is not intended to be used as a service (it is time consuming). Why make work for others? Answering in comments does new users a disservice by illustrating how not to do things! — Paul White ♦Jul 19, 2018 at 14:03
Today I saw the following statement in a code review:
ALTER TABLE dbo.MyTable ADD CreateDate DATETIME2(0) NOT NULL DEFAULT GETUTCDATE()
The GETUTCDATE() function returns a datetime and is then stuffed into a datetime2 column.
Does it have any significance that the two types are different? Would ...
@Zikato On that occasion, I stepped through the calls manually and kept a note of the order. There might be guides to using a debugger out there.
@Zikato My read of it focuses on the "code review". I think it's sloppy coding, but I don't know I'd make a fuss over it. Might be indicative of more usual sloppiness with data types.
Right. One might expect changing the precision of an already datedate2 value to be faster than converting datetime to datetime2. But expectations don't always work out. For all we know, sysutcdatetime is implemented more efficiently than getutcdate. And I really don't think performance is the main concern here. I might be wrong.
Thanks! 🙂 For sure. I feel like there was a decent chance I could've gotten it in 2 guesses with that start if I grinded the brain gears, but I was still way ahead the rest of my family who were averaging 5 guesses today lol
@HannahVernon Completely random fact, but I just realized you and Paul's timezones are exactly a half day apart lol. (Assuming he's in the GMT+13 TZ in NZ. Quite possible he's in the other one, idk.)
Aukland is 3:18am on Friday morning right now, and it's 9:18am Thursday here, so they're 18 hours ahead of us, but yes, it makes for good mod coverage when you consider that Paul only sleeps about 10 minutes a day (it seems)