Second pass (time zones, WINDOW, hashes, MERGE TOP)
The T-SQL that stage 7 left refused, built (D136) - datetimeoffset and AT TIME ZONE, DATE_BUCKET, the WINDOW clause, IGNORE NULLS, shift operators, MERGE TOP, HASHBYTES, COMPRESS, NEWSEQUENTIALID, TYPEPROPERTY, Hijri styles, ALTER TABLE ADD identity, Reduce.
Every item on this page is built in the SQL Server front-end.
Dates and time zones#
datetimeoffsetkeeps its offset.CAST('2024-07-01 12:00 +05:30' AS datetimeoffset), columns and variables of the type, everyCONVERTstyle SQL Server accepts for it (127gives UTC withZ),DATEPART(TZOFFSET, x),DATENAME(TZOFFSET, x),DATEADD, andDATEDIFFand comparisons on the UTC moment.x AT TIME ZONE 'Pacific Standard Time'with the 144 Windows zone names ofsys.time_zone_info, their daylight rules and their history (the table is generated from the Windows registry, which is where SQL Server reads it). A local time in the hour skipped in spring moves forward; one in the hour that comes twice in autumn takes the daylight offset - as SQL Server does. Every zone is covered for 2024 and for 1970-2040.SWITCHOFFSET,TODATETIMEOFFSET(offset as'+05:30'or minutes),DATE_BUCKET(with an origin),CONVERTstyles 22, 130 and 131 (the Hijri calendar of Microsoft's Kuwaiti algorithm, Arabic month names for 130) andFORMATof atime(the .NETTimeSpanformatsc,g,G,hh\:mm, ...).
Queries#
WINDOW w AS (PARTITION BY ... ORDER BY ...),OVER wandOVER (w ROWS BETWEEN ...).FIRST_VALUE/LAST_VALUE/LAG/LEAD ... IGNORE NULLS(andRESPECT NULLS).a << n,a >> n, andLEFT_SHIFT/RIGHT_SHIFTin the width of the value's type (CAST(-8 AS int) >> 1is2147483644).MERGE TOP (n) [PERCENT](not together withWHEN NOT MATCHED BY SOURCE).
Functions and DDL#
HASHBYTESwithMD2,MD4,MD5,SHA,SHA1,SHA2_256,SHA2_512, hashing the bytes SQL Server hashes (UTF-16 fornvarchar).COMPRESS/DECOMPRESS: GZIP; for short values the bytes are the ones SQL Server writes. For longer values SQL Server uses another kind of DEFLATE block and the bytes differ, but each side decompresses the other's.NEWSEQUENTIALID()as a column default,TYPEPROPERTY.ALTER TABLE t ADD id int IDENTITY(1, 1)on a table with rows: the rows are numbered in the table's order, as SQL Server numbers them.geometry.Reduce(tolerance)of points and lines.
Still refused#
hierarchyid- its binary encoding and a new user type are a stage of their own.STBuffer,BufferWithTolerance,MakeValid,Reduceof a polygon - SQL Server's answers carry the coordinates of its internal grid, which an independent implementation does not reproduce.FORMSOFandNEARwith a distance inCONTAINS.
The answers that differ are listed on Errors and limits.