Skip to content
OCTAVIIUS DOCSCore & Studio 0.2.83
SQL reference / 0.2.83

Scalar expressions and SQL functions

Conditional expressions, NULL handling, text, numeric and temporal functions.

Conditional expressions

CASE produces a conditional expression in a projection or calculation. COALESCE selects the first non-NULL value; NULLIF returns NULL when its arguments are equal. Branches should retain consistent types to stabilize conversions. Missing-value substitution must reflect a business rule: replacing NULL with zero changes averages and counts.

Strings, NULL and conditions

Strings: LEN, LOWER, UPPER, LEFT, RIGHT, SUBSTRING, REPLACE, REVERSE, STUFF, TRIM, LTRIM, RTRIM, CHARINDEX, PATINDEX, CONCAT and DATALENGTH. SUBSTRING/CHARINDEX positions are 1-based; CHARINDEX returns 0 when not found. CONCAT treats NULL as empty text. DATALENGTH reports expression-type size, not necessarily JSON or compressed-file size.

COALESCE accepts replacement candidates; NULLIF returns NULL when arguments compare equal; ISNULL and IIF have their own syntax. Do not assume universal lazy evaluation or another engine’s implicit rules.

SQL
SELECT CONCAT(N'Bonjour ', N'Alice') AS message,
 SUBSTRING(N'Octaviius', 1, 4) AS prefixe,
 CHARINDEX(N'vi', N'Octaviius') AS position;

Dates and numbers

Dates: GETDATE(), GETUTCDATE(), CURRENT_TIMESTAMP, SYSDATETIME(), SYSUTCDATETIME(), SYSDATETIMEOFFSET(), YEAR, MONTH, DAY, DATEADD, DATEDIFF, DATEDIFF_BIG, DATEPART, DATENAME, EOMONTH, DATEFROMPARTS, DATETRUNC and ISDATE. DATEADD/DATEPART take a recognized unit such as day, month or microsecond.

Numeric functions include ABS, ROUND, SIGN, CEILING, FLOOR, POWER, SQUARE, SQRT, PI, RAND, trigonometry, logarithms and exponentials. RAND uses Python random rather than SQL Server’s sequence. CHECKSUM/CHECKSUM_AGG use native typed CRC32/xor algorithms, not SQL Server checksums.

SQL
SELECT DATEADD(day, 1, CAST('2026-01-01' AS DATE)) AS lendemain,
 EOMONTH(CAST('2026-02-01' AS DATE)) AS fin_mois,
 ROUND(CAST('12.3456' AS DECIMAL(19,4)), 2) AS arrondi;

FORMAT and STRING_SPLIT

FORMAT implements common numeric/date patterns for explicitly recognized cultures, not the full .NET formatter. Prefer typed transport for client calculations and FORMAT for display. STRING_SPLIT is a table function with a separator and optional ordinal argument. Correlated APPLY and STRING_AGG WITHIN GROUP are unsupported. OBJECT_ID covers current-database tables/views; QUOTENAME delimits valid identifiers and returns NULL for out-of-bounds input.

SQL
SELECT value FROM STRING_SPLIT(N'a,b,c', N',');

FORMAT: supported cultures and patterns

Cultures: en-US, en-GB, fr-FR, fr-CA, de-DE, es-ES and pt-PT. Named months/weekdays are available only in English/French. Standard temporal patterns include d, D, s, o/O, t, T, g, G and u, plus common yyyy, MM, dd, HH, mm, ss, up to six f digits and K tokens. The u pattern may display a literal Z; it does not automatically convert a value to UTC.

Numeric patterns include N, F, C, P, D, X, E and G with optional precision up to 100 formatting digits; some #/0/grouping/decimal patterns are recognized. Unsupported patterns fail explicitly. Prefer typed DATE/DATETIMEOFFSET for interchange and formatting only for presentation.

Inventory and signatures

The inventory provides signatures and arity for scalar functions, aggregates and syntactic functions. Arity describes argument count; each family’s contract specifies types, conversions and domain limits. Window functions have partition and frame semantics described in the analytical reference.

FunctionSignatureArguments
ABSABS(expression)Special syntax
ACOSACOS(arg1)1
ASINASIN(arg1)1
ATANATAN(arg1)1
ATN2ATN2(arg1, arg2)2
AVGAVG([ALL|DISTINCT] expression)Special syntax
CASTCAST(expression AS type)Special syntax
CEILINGCEILING(arg1)1
CHARINDEXCHARINDEX(arg1, arg2 [, …])2..3
CHECKSUMCHECKSUM(arg1 [, …])1..1000
CHECKSUM_AGGCHECKSUM_AGG([ALL|DISTINCT] expression)Special syntax
COALESCECOALESCE(a, b, …)Special syntax
CONCATCONCAT(arg1, arg2 [, …])2..254
CONVERTCONVERT(type, expression [, style])Special syntax
COSCOS(arg1)1
COTCOT(arg1)1
COUNTCOUNT(*) / COUNT([DISTINCT] expression)Special syntax
COUNT_BIGCOUNT_BIG(*) / COUNT_BIG(expression)Special syntax
CURRENT_TIMESTAMPCURRENT_TIMESTAMPSpecial syntax
DATALENGTHDATALENGTH(arg1)1
DATEADDDATEADD(unit, amount, date)3
DATEDIFFDATEDIFF(unit, start, end)3
DATEDIFF_BIGDATEDIFF_BIG(unit, start, end)3
DATEFROMPARTSDATEFROMPARTS(arg1, arg2, arg3)3
DATENAMEDATENAME(unit, date)2
DATEPARTDATEPART(unit, date)2
DATETRUNCDATETRUNC(unit, date)2
DAYDAY(expression)Special syntax
DEGREESDEGREES(arg1)1
DENSE_RANKDENSE_RANK() OVER (…)Special syntax
EOMONTHEOMONTH(arg1 [, …])1..2
ERROR_LINEERROR_LINE()0
ERROR_MESSAGEERROR_MESSAGE()0
ERROR_NUMBERERROR_NUMBER()0
ERROR_PROCEDUREERROR_PROCEDURE()0
ERROR_SEVERITYERROR_SEVERITY()0
ERROR_STATEERROR_STATE()0
EXPEXP(arg1)1
FLOORFLOOR(arg1)1
FORMATFORMAT(arg1, arg2 [, …])2..3
GETDATEGETDATE()Special syntax
GETUTCDATEGETUTCDATE()Special syntax
GROUPINGGROUPING(arg1)1
GROUPING_IDGROUPING_ID(arg1 [, …])1..31
IIFIIF(arg1, arg2, arg3)3
ISDATEISDATE(arg1)1
ISNULLISNULL(value, replacement)Special syntax
LAGLAG(expression [, offset [, default]]) OVER (…)Special syntax
LEADLEAD(expression [, offset [, default]]) OVER (…)Special syntax
LEFTLEFT(arg1, arg2)2
LENLEN(expression)Special syntax
LOGLOG(arg1 [, …])1..2
LOG10LOG10(arg1)1
LOWERLOWER(expression)Special syntax
LTRIMLTRIM(arg1)1
MAXMAX([ALL|DISTINCT] expression)Special syntax
MINMIN([ALL|DISTINCT] expression)Special syntax
MONTHMONTH(expression)Special syntax
NTILENTILE(n) OVER (…)Special syntax
NULLIFNULLIF(a, b)Special syntax
OBJECT_IDOBJECT_ID(arg1 [, …])1..2
PATINDEXPATINDEX(arg1, arg2)2
PIPI()0
POWERPOWER(arg1, arg2)2
QUOTENAMEQUOTENAME(arg1 [, …])1..2
RADIANSRADIANS(arg1)1
RANDRAND( [, …])0..1
RANKRANK() OVER (…)Special syntax
REPLACEREPLACE(arg1, arg2, arg3)3
REVERSEREVERSE(arg1)1
RIGHTRIGHT(arg1, arg2)2
ROUNDROUND(value, decimals)Special syntax
ROW_NUMBERROW_NUMBER() OVER (…)Special syntax
RTRIMRTRIM(arg1)1
SIGNSIGN(arg1)1
SINSIN(arg1)1
SQRTSQRT(arg1)1
SQUARESQUARE(arg1)1
STDEVSTDEV([ALL|DISTINCT] expression)Special syntax
STDEVPSTDEVP([ALL|DISTINCT] expression)Special syntax
STRING_AGGSTRING_AGG(expression, separator)Special syntax
STRING_SPLITSTRING_SPLIT(text, separator [, ordinal])Special syntax
STUFFSTUFF(arg1, arg2, arg3, arg4)4
SUBSTRINGSUBSTRING(arg1, arg2, arg3)3
SUMSUM([ALL|DISTINCT] expression)Special syntax
SYSDATETIMESYSDATETIME()0
SYSDATETIMEOFFSETSYSDATETIMEOFFSET()0
SYSUTCDATETIMESYSUTCDATETIME()0
TANTAN(arg1)1
TRIMTRIM(arg1 [, …])1..2
UPPERUPPER(expression)Special syntax
VARVAR([ALL|DISTINCT] expression)Special syntax
VARPVARP([ALL|DISTINCT] expression)Special syntax
YEARYEAR(expression)Special syntax