Conceptual Model Canonical to SQL Server Functions Mapping
This topic describes how conceptual model canonical functions map to the corresponding SQL Server functions.
Date and Time Functions
The following table describes the date and time functions mapping:
Canonical functions | SQL Server functions |
---|---|
DATEADD(day, number, date) |
|
DATEADD(hour, number, date) |
|
DATEADD(microsecond, number, date) |
|
DATEADD(millisecond, number, date) |
|
DATEADD(minute, number, date) |
|
DATEADD(month, number, date) |
|
DATEADD(nanosecond, number, date) |
|
DATEADD(second, number, date) |
|
DATEADD(year, number, date) |
|
For SQL Server 2000 and SQL Server 2005, a datetime formatted value is created on the server. For SQL Server 2008 and later versions, a datetime2 value is created on the server. |
|
CreateDateTimeOffset(year, month, day, hour, minute, second, tzoffset) |
A datetimeoffset formatted value is created on the server. Not supported in SQL Server 2000 or SQL Server 2005. |
A time formatted value is created on the server. Not supported in SQL Server 2000 or SQL Server 2005. |
|
SysDateTime() in SQLServer 2008. GetDate() in SQLServer 2000 and SQLServer 2005. |
|
SysDateTimeOffset() in SQL Server 2008. Not supported in SQL Server 2000 or SQL Server 2005. |
|
SysUtcDateTime() in SQLServer 2008. GetUtcDate() in SQL Server 2000 and SQL Server 2005. |
|
DatePart(dayofyear, expression) |
|
DatePart(day, expression) |
|
DATEDIFF(day, startdate, enddate) |
|
DATEDIFF(hour, startdate, enddate) |
|
DATEDIFF(microsecond, startdate, enddate) |
|
DATEDIFF(millisecond, startdate, enddate) |
|
DATEDIFF(minute, startdate, enddate) |
|
DATEDIFF(nanosecond, startdate, enddate) |
|
DATEDIFF(second, startdate, enddate) |
|
DATEDIFF(year, startdate, enddate) |
|
DatePart(tzoffset, expression) |
|
DatePart(hour, expression) |
|
DatePart(millisecond, expression) |
|
DatePart(minute, expression) |
|
DatePart(month, expression) |
|
DatePart(second, expression) |
|
For SQL Server 2000 and SQL Server 2005, a truncated datetime formatted value is created on the server. For SQL Server 2008 and later versions, a truncated datetime2 or datetimeoffset value is created on the server. |
|
DatePart(YEAR, expression) |
Aggregate Functions
The following table describes the aggregate functions mapping:
Canonical functions | SQL Server functions |
---|---|
AVG(expression) |
|
BIGCOUNT(expression) |
|
COUNT(expression) |
|
MIN(expression) |
|
MAX(expression) |
|
STDEV(expression) |
|
STDEVP(expression) |
|
SUM(expression) |
|
VAR(expression) |
|
VARP(expression) |
Math functions
The following table describes the math functions mapping:
Canonical functions | SQL Server functions |
---|---|
ABS(value) |
|
CEILING(value) |
|
FLOOR(value) |
|
POWER(value, exponent) |
|
ROUND(value, digits, 0) |
|
ROUND(value , digits, 1) |
String Functions
The following table describes the string functions mapping:
Canonical functions | SQL Server functions |
---|---|
CHARINDEX(target, string) |
|
string1 + string2 |
|
CHARINDEX(REVERSE(target), REVERSE(string)) = 1 Note The CHARINDEX function returns false if the string is stored in a fixed length string column and target is a constant. In this case, the entire string is searched, including any padding trailing spaces. A possible workaround is to trim the data in the fixed length string before passing the string to the |
|
CHARINDEX(target, string2) |
|
LEFT(string1, length) |
|
LEN(string) |
|
LTRIM(string) |
|
RIGHT (string1, length) |
|
LTRIM(RTRIM(string)) |
|
REPLACE(string1, string2, string3) |
|
REVERSE (string) |
|
RTRIM(string) |
|
CHARINDEX(target, string) |
|
SUBSTRING(string, start, length) |
|
LOWER(string) |
|
UPPER(string) |
Bitwise Functions
The following table describes the bitwise functions mapping:
Canonical functions | SQL Server functions |
---|---|
value1 & value2 |
|
~value |
|
value1 | value2 |
|
value1 ^ value2 |