Finding expression type.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sun, 19 Feb 2023 23:59:55 +0200
changeset 2560 e023a7bbaf3b
parent 2559 42551ca22ca3
child 2561 37a80bcdba4b
Finding expression type.
sqlserver.rst
--- a/sqlserver.rst	Mon Feb 13 14:31:41 2023 +0200
+++ b/sqlserver.rst	Sun Feb 19 23:59:55 2023 +0200
@@ -13,6 +13,7 @@
   SELECT * FROM sys.tables;
   SELECT * FROM sys.views;
   SELECT * FROM sys.indexes;
+  SELECT * FROM sys.types;
 
   SELECT * FROM information_schema.tables;
 
@@ -34,3 +35,20 @@
 
   SELECT name, description FROM sys.fn_helpcollations();
 
+Finding expression type
+=======================
+
+::
+
+  SELECT SQL_VARIANT_PROPERTY(current_timestamp, 'BaseType');
+  SELECT SQL_VARIANT_PROPERTY(current_timestamp, 'Precision');
+  SELECT SQL_VARIANT_PROPERTY(current_timestamp, 'Scale');
+  SELECT SQL_VARIANT_PROPERTY(current_timestamp, 'MaxLength');
+
+Number of bytes required to hold both the metadata and data of the value::
+
+  SELECT SQL_VARIANT_PROPERTY(current_timestamp, 'TotalBytes');
+
+https://learn.microsoft.com/en-us/sql/t-sql/functions/sql-variant-property-transact-sql
+  SQL_VARIANT_PROPERTY (Transact-SQL).
+