T-SQL: stage 9
What stage 9 (D146) built - hierarchyid, more geometry and geography methods, the catalog answers tools read, MERGE TOP with BY SOURCE, binary shifts, defaults of existing columns, implicit transactions, TLS settings - and what is decided out of scope.
This page lists what stage 9 (D146) added to the SQL Server front-end and what it leaves refused.
hierarchyid#
- The type: columns, variables, parameters (the CLR type
SqlHierarchyIdon the wire, which .NET reads as aSqlHierarchyId), keys and indexes. A value is kept in the OrdPath byte encoding, so tables keyed byhierarchyidsort depth first. - Methods:
hierarchyid::GetRoot(),hierarchyid::Parse(),ToString(),GetLevel(),GetAncestor(n),GetDescendant(c1, c2),IsDescendantOf(),GetReparentedValue();CASTto and from text andvarbinary; text such as'/1/2/'converts to it inINSERT,UPDATE, comparisons and method arguments. - Errors: 6522 (with the numbers 24001, 24007, 24008, 24009, 24011), 403, 529.
sys.types,sys.columnsandINFORMATION_SCHEMAlist the type. A computed column may be written without parentheses (lvl AS node.GetLevel() PERSISTED). Read/Writeare not callable from T-SQL.
geometry and geography#
- Built:
STConvexHull,STIsValidandIsValidDetailed(24400, 24404, 24406, 24411, 24413),STBoundary,STIsSimple,MakeValidof a valid shape,Reduceof polygons,STBuffer/BufferWithToleranceof points;geographySTDistanceandSTLengthon the WGS 84 ellipsoid andSTAreaon the authalic sphere. - Refused (error 40000):
STUnion,STIntersection,STDifference,STSymDifference(they were listed as supported before, but were not),STBufferof lines and polygons,MakeValidof an invalid shape,geographybuffers and hulls.
Catalog and tools#
sys.check_constraints, sys.computed_columns, sys.default_constraints and INFORMATION_SCHEMA.COLUMNS show definitions in SQL Server's stored form (([amount]>=(0)), ((1)), (getdate())); INCLUDE columns of an index; default constraints in sys.objects; sp_helpconstraint, sp_helpuser, sp_statistics, sp_sproc_columns, sp_sproc_columns_100, sp_columns_100 in SQL Server's layout.
Statements and functions#
MERGE TOP (n)withWHEN NOT MATCHED BY SOURCE(rows taken in the order of theONkey; theONcondition needs an equality of a target and a source column);@@ROWCOUNTafterMERGEwithNOCOUNT ON.ALTER TABLE .. ADD [CONSTRAINT ..] DEFAULT expr FOR columnwith any expression (getutcdate(),newid(),NEWSEQUENTIALID()), andDROP CONSTRAINTof a named default. AnIDENTITYseed other than 1 is kept.<</>>/LEFT_SHIFT/RIGHT_SHIFTofbinaryandvarbinaryvalues;CASTbetween whole numbers andbinary;datetime - datetime;UPPER/LOWERchange one character for one; error 8127 forORDER BYof a column that is not grouped.CONVERTof text to a date with styles 22, 130 and 131.SET IMPLICIT_TRANSACTIONS ON(what JDBC and ODBC drivers send when auto-commit is off): a statement that reads or changes a table opens a transaction.- Forms seen in real scripts: comparisons written with a blank (
! =,< =), old table hints (t (NOLOCK)), hints on the target ofUPDATE/DELETE, a function withoutAS,TOPin aUNIONbranch,FOR XML PATH('')to concatenate text, a CTE beforeINSERT,sp_renameof a column,sp_MSforeachtable.
Connections#
raftdb-mssql takes --ssl auto (a generated certificate), --ssl-cert FILE --ssl-key FILE and --ssl-mode login|preferred|required; a client that asks for encryption gets the whole connection under TLS, and sys.dm_exec_connections.encrypt_option says TRUE.
Server level#
sp_configure (read), DBCC USEROPTIONS / OPENTRAN / CHECKIDENT / CHECKTABLE / CHECKDB, the fixed server roles, IS_SRVROLEMEMBER, SUSER_SID answer in SQL Server's layout. SQL Server Agent jobs run inside Raft DB (see stage 6); the msdb tables do not have every column SQL Server's have.
Out of scope#
CLR (assemblies: error 6263), Service Broker, Always Encrypted keys, replication, SSIS and linked servers are not part of the front-end. They are refused with the numbers SQL Server gives on a server where none of them is set up: 7202 for OPENQUERY, four-part names and EXEC .. AT; 8426 for SEND; 208 for RECEIVE and BEGIN DIALOG; 15151 for OPEN SYMMETRIC KEY; 15281 for OPENROWSET / OPENDATASOURCE; 15010 for sp_replicationdboption of a database that does not exist; 40000 for the linked-server and replication procedures.