it-swarm-eu.dev

Existuje analog GETDATE (), který vrací DATETIME2

Podle MSDN se Getdate (), GetUtcDate () a CURRENT_TIMESTAMP vrátí DATETIME. Udělal jsem krátký test, který potvrzuje, že:

CREATE TABLE #t(T DATETIME2(7));
GO

DECLARE @i INT ;
SET @i=1;

WHILE @i<10000 BEGIN ;
INSERT #t VALUES(CURRENT_TIMESTAMP) ;
SET @[email protected]+1;
END ;

SELECT DISTINCT t 
FROM #t 
ORDER BY t ;

---

2013-01-28 13:23:19.4930000
2013-01-28 13:23:19.4970000
2013-01-28 13:23:19.5000000
2013-01-28 13:23:19.5030000
2013-01-28 13:23:19.5070000
2013-01-28 13:23:19.5100000
2013-01-28 13:23:19.5130000

(stříhat)

Existuje podobná funkce, která vrací DATETIME2 (7)?

42
A-K

SYSDATETIME vrátí DATETIME2 objekt.

CREATE TABLE #t(T DATETIME2(7));
GO

DECLARE @i INT ;
SET @i=1;

WHILE @i<10000 BEGIN ;
INSERT #t VALUES(SYSDATETIME()) ;
SET @[email protected]+1;
END ;

SELECT DISTINCT t 
FROM #t 
ORDER BY t ;



2013-01-28 12:34:28.2514394
2013-01-28 12:34:28.2670399
2013-01-28 12:34:28.2826404
2013-01-28 12:34:28.2982409
2013-01-28 12:34:28.3138414
2013-01-28 12:34:28.3294419
2013-01-28 12:34:28.3450424
2013-01-28 12:34:28.3606429
2013-01-28 12:34:28.3762434
2013-01-28 12:34:28.3918439
2013-01-28 12:34:28.4074444
2013-01-28 12:34:28.4230449
2013-01-28 12:34:28.4386454
2013-01-28 12:34:28.4542459
2013-01-28 12:34:28.4698464
53
swasheck