Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
In questo argomento viene descritto il mapping delle funzioni canoniche del modello concettuale alle funzioni di SQL Server corrispondenti.
Funzioni di data e ora
La tabella seguente descrive il mapping delle funzioni di data e ora:
| Funzioni canoniche | Funzioni di SQL Server |
|---|---|
| AddDays(expression) | DATEADD(day, number, date) |
| AddHours(expression) | DATEADD(hour, number, date) |
| AddMicroseconds(expression) | DATEADD(microsecond, number, date) |
| AddMilliseconds(expression) | DATEADD(millisecond, number, date) |
| AddMinutes(expression) | DATEADD(minute, number, date) |
| AddMonths(expression) | DATEADD(month, number, date) |
| AddNanoseconds(expression) | DATEADD(nanosecond, number, date) |
| AddSeconds(expression) | DATEADD(second, number, date) |
| AddYears(expression) | DATEADD(year, number, date) |
| CreateDateTime(year, month, day, hour, minute, second) | Per SQL Server 2000 e SQL Server 2005, viene creato un datetime valore formattato nel server. Per SQL Server 2008 e versioni successive, viene creato un datetime2 valore nel server. |
| CreateDateTimeOffset(year, month, day, hour, minute, second, tzoffset) | Nel server viene creato un datetimeoffset valore formattato.Non supportato in SQL Server 2000 o SQL Server 2005. |
| CreateTime(hour, minute, second) | Nel server viene creato un time valore formattato.Non supportato in SQL Server 2000 o SQL Server 2005. |
| CurrentDateTime() |
SysDateTime() in SQLServer 2008.GetDate() in SQLServer 2000 e SQLServer 2005. |
| CurrentDateTimeOffset() |
SysDateTimeOffset() in SQL Server 2008.Non supportato in SQL Server 2000 o SQL Server 2005. |
| CurrentUtcDateTime() |
SysUtcDateTime() in SQLServer 2008.
GetUtcDate() in SQL Server 2000 e SQL Server 2005. |
| DayOfYear(expression) | DatePart(dayofyear, expression) |
| Day(expression) | DatePart(day, expression) |
| DiffDays(startExpression, endExpression) | DATEDIFF(day, startdate, enddate) |
| DiffHours(startExpression, endExpression) | DATEDIFF(hour, startdate, enddate) |
| DiffMicroseconds(startExpression, endExpression) | DATEDIFF(microsecond, startdate, enddate) |
| DiffMilliseconds(startExpression, endExpression) | DATEDIFF(millisecond, startdate, enddate) |
| DiffMinutes(startExpression, endExpression) | DATEDIFF(minute, startdate, enddate) |
| DiffNanoseconds(startExpression, endExpression) | DATEDIFF(nanosecond, startdate, enddate) |
| DiffSeconds(startExpression, endExpression) | DATEDIFF(second, startdate, enddate) |
| DiffYears(startExpression, endExpression) | DATEDIFF(year, startdate, enddate) |
| GetTotalOffsetMinutes(DateTimeOffset) | DatePart(tzoffset, expression) |
| Hour(expression) | DatePart(hour, expression) |
| Millisecond(expression) | DatePart(millisecond, expression) |
| Minute(expression) | DatePart(minute, expression) |
| Month(expression) | DatePart(month, expression) |
| Second(expression) | DatePart(second, expression) |
| Truncate(expression) | Per SQL Server 2000 e SQL Server 2005, viene creato un valore formattato troncato datetime nel server. Per SQL Server 2008 e versioni successive, viene creato un valore datetime2 o datetimeoffset troncato sul server. |
| Year(expression) | DatePart(YEAR, expression) |
Funzioni di aggregazione
La tabella seguente descrive il mapping delle funzioni di aggregazione:
| Funzioni canoniche | Funzioni di SQL Server |
|---|---|
| Avg(expression) | AVG(expression) |
| BigCount(expression) | BIGCOUNT(expression) |
| Count(expression) | COUNT(expression) |
| Min(expression) | MIN(expression) |
| Max(expression) | MAX(expression) |
| StDev(expression) | STDEV(expression) |
| StDevP(expression) | STDEVP(expression) |
| Sum(expression) | SUM(expression) |
| Var(expression) | VAR(expression) |
| VarP(expression) | VARP(expression) |
Funzioni matematiche
La tabella seguente descrive il mapping delle funzioni matematiche:
| Funzioni canoniche | Funzioni di SQL Server |
|---|---|
| Abs(value) | ABS(value) |
| Ceiling(value) | CEILING(value) |
| Floor(value) | FLOOR(value) |
| Power(value) | POWER(value, exponent) |
| Round(value) | ROUND(value, digits, 0) |
| Tronca | ROUND(value , digits, 1) |
Funzioni Stringa
Nella tabella seguente viene descritto il mapping delle funzioni di stringhe.
| Funzioni canoniche | Funzioni di SQL Server |
|---|---|
| Contiene(stringa, obiettivo) | CHARINDEX(target, string) |
| Concat(string1, string2) | string1 + string2 |
| EndsWith(string, target) | CHARINDEX(REVERSE(target), REVERSE(string)) = 1Nota La CHARINDEX funzione restituisce false se l'oggetto string viene archiviato in una colonna stringa a lunghezza fissa ed target è una costante. In questo caso, viene eseguita la ricerca dell'intera stringa, inclusi gli spazi di riempimento finali. Una possibile soluzione alternativa consiste nel tagliare i dati nella stringa a lunghezza fissa prima di passare la EndsWith stringa alla funzione, come nell'esempio seguente: EndsWith(TRIM(string), target) |
| IndexOf(target, string2) | CHARINDEX(target, string2) |
| Sinistra (string1, length) | LEFT(string1, length) |
| Lunghezza (stringa) | LEN(string) |
| LTrim(string) | LTRIM(string) |
| Destra (string1, length) | RIGHT (string1, length) |
| Trim(string) | LTRIM(RTRIM(string)) |
| Replace (string1, string2, string3) | REPLACE(string1, string2, string3) |
| Inverso (stringa) | REVERSE (string) |
| RTrim(string) | RTRIM(string) |
| StartsWith(string, target) | CHARINDEX(target, string) |
| Substring(string, start, length) | SUBSTRING(string, start, length) |
| ToLower(string) | LOWER(string) |
| ToUpper(string) | UPPER(string) |
Funzioni bit per bit
La tabella seguente descrive il mapping delle funzioni bit per bit:
| Funzioni canoniche | Funzioni di SQL Server |
|---|---|
| BitWiseAnd (value1, value2) | value1 & value2 |
| BitWiseNot (valore) | ~valore |
| BitWiseOr (value1, value2) | valore1 | valore2 |
| BitWiseXor (value1, value2) | value1 ^ value2 |