August 10, 2017 at 7:48 pm
Steve Jones - SSC Editor - Thursday, August 10, 2017 5:38 PMGETDATE() can also be much faster at scale. If you're just looking for days/hours/minutes/seconds, why not use datetime?
No one would like to prove that to be true more than I... but I'm not seeing it to be true. Do you have an example of what you're speaking of because I'm not seeing it in the following simple test.
CREATE TABLE #DT (DT DATETIME);
CREATE TABLE #DT2 (DT2 DATETIME2(3));
SET STATISTICS TIME ON;
GO
INSERT INTO #DT(DT)
SELECT TOP 10000000
GETDATE()
FROM sys.all_columns ac1
CROSS JOIN sys.all_columns ac2
;
GO
INSERT INTO #DT2(DT2)
SELECT TOP 10000000
SYSDATETIME()
FROM sys.all_columns ac1
CROSS JOIN sys.all_columns ac2
;
GO
DROP TABLE #DT,#DT2
;
--Jeff Moden
Change is inevitable... Change for the better is not.
August 10, 2017 at 9:35 pm
I saw a test, but can't find it now, nor am I allowed since I only had a few minutes before everyone woke up. Now that I think of it, perhaps the issue was conversion of datetime2 -> datetime as many functions use this? Not sure, but I was surprised to see someone show a datetime2 being slower than datetime in a situation.
Viewing 2 posts - 16 through 16 (of 16 total)
You must be logged in to reply to this topic. Login to reply