Class SqlFn
- Namespace
- LinqToDB.DataProvider.SqlServer
- Assembly
- linq2db.dll
public static class SqlFn
- Inheritance
-
SqlFn
Properties
Connections
This function returns the number of attempted connections - both successful and unsuccessful - since SQL Server was last started.
[Sql.Expression("SqlServer", "@@CONNECTIONS", ServerSideOnly = true)]
public static int Connections { get; }
Property Value
- int
integer
Exceptions
CpuBusy
This function returns the amount of time that SQL Server has spent in active operation since its latest start.
[Sql.Expression("SqlServer", "@@CPU_BUSY", ServerSideOnly = true)]
public static int CpuBusy { get; }
Property Value
- int
integer
Exceptions
CurrentTimestamp
CURRENT_TIMESTAMP (Transact-SQL)
This function returns the current database system timestamp as a datetime value, without the database time zone offset.
CURRENT_TIMESTAMP
derives this value from the operating system of the computer on which the instance of SQL Server runs.
[Sql.Expression("SqlServer", "CURRENT_TIMESTAMP", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static DateTime CurrentTimestamp { get; }
Property Value
- DateTime
datetime
Exceptions
DateFirst
This function returns the current value of SET DATEFIRST, for a specific session.
[Sql.Expression("SqlServer", "@@DATEFIRST", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static byte DateFirst { get; }
Property Value
- byte
tinyint
Exceptions
DbTS
This function returns the value of the current timestamp data type for the current database. The current database will have a guaranteed unique timestamp value.
[Sql.Expression("SqlServer", "@@DBTS", ServerSideOnly = true)]
public static byte[] DbTS { get; }
Property Value
- byte[]
varbinary
Exceptions
IOBusy
Returns the time that SQL Server has spent performing input and output operations since SQL Server was last started.
[Sql.Expression("SqlServer", "@@IO_BUSY", ServerSideOnly = true)]
public static int IOBusy { get; }
Property Value
- int
integer
Exceptions
Identity
Is a system function that returns the last-inserted identity value.
[Sql.Expression("SqlServer", "@@IDENTITY", ServerSideOnly = true)]
public static decimal? Identity { get; }
Property Value
- decimal?
numeric(38,0)
Exceptions
Idle
Returns the time that SQL Server has been idle since it was last started.
[Sql.Expression("SqlServer", "@@IDLE", ServerSideOnly = true)]
public static int Idle { get; }
Property Value
- int
integer
Exceptions
LangID
Returns the local language identifier (ID) of the language that is currently being used.
[Sql.Expression("SqlServer", "@@LANGID", ServerSideOnly = true)]
public static short LangID { get; }
Property Value
- short
smallint
Exceptions
Language
Returns the name of the language currently being used.
[Sql.Expression("SqlServer", "@@LANGUAGE", ServerSideOnly = true)]
public static string Language { get; }
Property Value
- string
nvarchar
Exceptions
LockTimeout
Returns the current lock time-out setting in milliseconds for the current session.
[Sql.Expression("SqlServer", "@@LOCK_TIMEOUT", ServerSideOnly = true)]
public static int LockTimeout { get; }
Property Value
- int
integer
Exceptions
MaxConnections
@@MAX_CONNECTIONS (Transact-SQL)
Returns the maximum number of simultaneous user connections allowed on an instance of SQL Server. The number returned is not necessarily the number currently configured.
[Sql.Expression("SqlServer", "@@MAX_CONNECTIONS", ServerSideOnly = true)]
public static int MaxConnections { get; }
Property Value
- int
integer
Exceptions
MaxPrecision
@@MAX_PRECISION (Transact-SQL)
Returns the precision level used by decimal and numeric data types as currently set in the server.
[CLSCompliant(false)]
[Sql.Expression("SqlServer", "@@MAX_PRECISION", ServerSideOnly = true)]
public static byte MaxPrecision { get; }
Property Value
- byte
tinyint
Exceptions
NestLevel
Returns the nesting level of the current stored procedure execution (initially 0) on the local server.
[Sql.Expression("SqlServer", "@@NESTLEVEL", ServerSideOnly = true)]
[CLSCompliant(false)]
public static int NestLevel { get; }
Property Value
- int
int
Exceptions
Options
Returns information about the current SET options.
[Sql.Expression("SqlServer", "@@OPTIONS", ServerSideOnly = true)]
public static int Options { get; }
Property Value
- int
integer
Exceptions
PackReceived
@@PACK_RECEIVED (Transact-SQL)
Returns the number of input packets read from the network by SQL Server since it was last started.
[Sql.Expression("SqlServer", "@@PACK_RECEIVED", ServerSideOnly = true)]
public static int PackReceived { get; }
Property Value
- int
integer
Exceptions
PackSent
Returns the number of output packets written to the network by SQL Server since it was last started.
[Sql.Expression("SqlServer", "@@PACK_SENT", ServerSideOnly = true)]
public static int PackSent { get; }
Property Value
- int
integer
Exceptions
PacketErrors
@@PACKET_ERRORS (Transact-SQL)
Returns the number of network packet errors that have occurred on SQL Server connections since SQL Server was last started.
[Sql.Expression("SqlServer", "@@PACKET_ERRORS", ServerSideOnly = true)]
public static int PacketErrors { get; }
Property Value
- int
integer
Exceptions
RemServer
Returns the name of the remote SQL Server database server as it appears in the login record.
[Sql.Expression("SqlServer", "@@REMSERVER", ServerSideOnly = true)]
public static string? RemServer { get; }
Property Value
- string
nvarchar(128)
Exceptions
RowCount
Returns the number of rows affected by the last statement. If the number of rows is more than 2 billion, use ROWCOUNT_BIG.
[Sql.Expression("SqlServer", "@@ROWCOUNT", ServerSideOnly = true)]
public static int RowCount { get; }
Property Value
- int
int
Exceptions
ServerName
Returns the name of the local server that is running SQL Server.
[Sql.Expression("SqlServer", "@@SERVERNAME", ServerSideOnly = true)]
public static string ServerName { get; }
Property Value
- string
nvarchar
Exceptions
ServiceName
Returns the name of the registry key under which SQL Server is running. @@SERVICENAME returns 'MSSQLSERVER' if the current instance is the default instance; this function returns the instance name if the current instance is a named instance.
[Sql.Expression("SqlServer", "@@SERVICENAME", ServerSideOnly = true)]
public static string ServiceName { get; }
Property Value
- string
nvarchar
Exceptions
SpID
Returns the session ID of the current user process.
[Sql.Expression("SqlServer", "@@SPID", ServerSideOnly = true)]
public static short SpID { get; }
Property Value
- short
smallint
Exceptions
TextSize
Returns the current value of the TEXTSIZE option.
[Sql.Expression("SqlServer", "@@TEXTSIZE", ServerSideOnly = true)]
public static int TextSize { get; }
Property Value
- int
integer
Exceptions
TimeTicks
Returns the number of microseconds per tick.
[Sql.Expression("SqlServer", "@@TIMETICKS", ServerSideOnly = true)]
public static int TimeTicks { get; }
Property Value
- int
integer
Exceptions
TotalErrors
Returns the number of microseconds per tick.
[Sql.Expression("SqlServer", "@@TOTAL_ERRORS", ServerSideOnly = true)]
public static int TotalErrors { get; }
Property Value
- int
integer
Exceptions
TotalRead
Returns the number of microseconds per tick.
[Sql.Expression("SqlServer", "@@TOTAL_READ", ServerSideOnly = true)]
public static int TotalRead { get; }
Property Value
- int
integer
Exceptions
TotalWrite
Returns the number of microseconds per tick.
[Sql.Expression("SqlServer", "@@TOTAL_WRITE", ServerSideOnly = true)]
public static int TotalWrite { get; }
Property Value
- int
integer
Exceptions
TransactionCount
Returns the number of input packets read from the network by SQL Server since it was last started.
[Sql.Expression("SqlServer", "@@TRANCOUNT", ServerSideOnly = true)]
public static int TransactionCount { get; }
Property Value
- int
integer
Exceptions
Version
Returns system and build information for the current installation of SQL Server.
[Sql.Expression("SqlServer", "@@VERSION", ServerSideOnly = true)]
public static string Version { get; }
Property Value
- string
nvarchar
Exceptions
Methods
Abs<T>(T)
A mathematical function that returns the absolute (positive) value of the specified numeric expression.
(ABS
changes negative values to positive values. ABS
has no effect on zero or positive values.)
[Sql.Function("SqlServer", "ABS", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Abs<T>(T numeric_expression)
Parameters
numeric_expression
TAn expression of the exact numeric or approximate numeric data type category.
Returns
- T
Returns the same type as numeric_expression.
Type Parameters
T
Exceptions
Acos<T>(T)
A function that returns the angle, in radians, whose cosine is the specified float expression. This is also called arccosine.
[Sql.Function("SqlServer", "ACOS", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Acos<T>(T float_expression)
Parameters
float_expression
TAn expression of either type float or of a type that can implicitly convert to float. Only a value ranging from -1.00 to 1.00 is valid. For values outside this range, no value is returned, and ACOS will report a domain error.
Returns
- T
float
Type Parameters
T
Exceptions
AppName()
This function returns the application name for the current session, if the application sets that name value.
[Sql.Function("SqlServer", "APP_NAME", ServerSideOnly = true)]
public static string AppName()
Returns
- string
nvarchar(128)
Exceptions
Ascii(char)
Returns the ASCII code value of the leftmost character of a character expression.
[Sql.Function("SqlServer", "ASCII", ServerSideOnly = true)]
public static int Ascii(char character_expression)
Parameters
character_expression
charAn expression of type char or varchar.
Returns
- int
int
Exceptions
Ascii(string?)
Returns the ASCII code value of the leftmost character of a character expression.
[Sql.Function("SqlServer", "ASCII", ServerSideOnly = true)]
public static int? Ascii(string? character_expression)
Parameters
character_expression
stringAn expression of type char or varchar.
Returns
- int?
int
Exceptions
Asin<T>(T)
A function that returns the angle, in radians, whose sine is the specified float expression. This is also called arcsine.
[Sql.Function("SqlServer", "ASIN", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Asin<T>(T float_expression)
Parameters
float_expression
TAn expression of either type float or of a type that can implicitly convert to float. Only a value ranging from -1.00 to 1.00 is valid. For values outside this range, no value is returned, and ASIN will report a domain error.
Returns
- T
float
Type Parameters
T
Exceptions
Atan<T>(T)
A function that returns the angle, in radians, whose tangent is a specified float expression. This is also called arctangent.
[Sql.Function("SqlServer", "ATAN", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Atan<T>(T float_expression)
Parameters
float_expression
TAn expression of either type float or of a type that implicitly convert to float.
Returns
- T
float
Type Parameters
T
Exceptions
Atn2<T>(T, T)
Returns the angle, in radians, between the positive x-axis and the ray from the origin to the point (y, x), where x and y are the values of the two specified float expressions.
[Sql.Function("SqlServer", "ATN2", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Atn2<T>(T float_expression, T float_expression2)
Parameters
float_expression
TAn expression of type float.
float_expression2
T
Returns
- T
float
Type Parameters
T
Exceptions
BinaryCheckSum()
BINARY_CHECKSUM (Transact-SQL)
Returns the binary checksum value computed over a row of a table or over a list of expressions.
[Sql.Expression("SqlServer", "BINARY_CHECKSUM(*)", ServerSideOnly = true)]
public static int BinaryCheckSum()
Returns
- int
int
Exceptions
BinaryCheckSum(params object[])
BINARY_CHECKSUM (Transact-SQL)
Returns the binary checksum value computed over a row of a table or over a list of expressions.
[Sql.Function("SqlServer", "BINARY_CHECKSUM", ServerSideOnly = true)]
public static int BinaryCheckSum(params object[] expressions)
Parameters
expressions
object[]An expression of any type. BINARY_CHECKSUM ignores expressions of noncomparable data types in its computation.
Returns
- int
int
Exceptions
Cast<T>(object?)
CAST and CONVERT (Transact-SQL)
These functions convert an expression of one data type to another.
[Sql.Expression("SqlServer", "CAST({0} as {1})", ServerSideOnly = true)]
public static T Cast<T>(object? expression)
Parameters
expression
objectAny valid expression.
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
Cast<T>(object?, SqlType<T>)
CAST and CONVERT (Transact-SQL)
These functions convert an expression of one data type to another.
[Sql.Extension("SqlServer", "CAST({expression} as {data_type})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T Cast<T>(object? expression, SqlType<T> data_type)
Parameters
expression
objectAny valid expression.
data_type
SqlType<T>The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
Cast<T>(object?, Func<SqlType<T>>)
CAST and CONVERT (Transact-SQL)
These functions convert an expression of one data type to another.
[Sql.Extension("SqlServer", "CAST({expression} as {data_type})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T Cast<T>(object? expression, Func<SqlType<T>> data_type)
Parameters
expression
objectAny valid expression.
data_type
Func<SqlType<T>>The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
Ceiling<T>(T)
This function returns the smallest integer greater than, or equal to, the specified numeric expression.
[Sql.Function("SqlServer", "CEILING", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Ceiling<T>(T numeric_expression)
Parameters
numeric_expression
TAn expression of the exact numeric or approximate numeric data type category. For this function, the bit data type is invalid.
Returns
- T
Return values have the same type as
numeric_expression
.
Type Parameters
T
Exceptions
Char(int?)
Returns the ASCII code value of the leftmost character of a character expression.
[Sql.Function("SqlServer", "CHAR", ServerSideOnly = true)]
public static char? Char(int? integer_expression)
Parameters
integer_expression
int?An integer from 0 through 255.
CHAR
returns aNULL
value for integer expressions outside this input range or not representing a complete character.CHAR
also returns aNULL
value when the character exceeds the length of the return type. Many common character sets share ASCII as a sub-set and will return the same character for integer values in the range 0 through 127.
Returns
- char?
char(1)
Exceptions
CharIndex(string?, string?)
This function searches for one character expression inside a second character expression, returning the starting position of the first expression if found.
[Sql.Function("SqlServer", "CHARINDEX", ServerSideOnly = true)]
public static int? CharIndex(string? expressionToFind, string? expressionToSearch)
Parameters
expressionToFind
stringA character expression containing the sequence to find.
expressionToFind
has an 8000 character limit.expressionToSearch
stringA character expression to search.
Returns
- int?
bigint if
expressionToSearch
has an nvarchar(max), varbinary(max), or varchar(max) data type; int otherwise.
Exceptions
CharIndex(string?, string?, int?)
This function searches for one character expression inside a second character expression, returning the starting position of the first expression if found.
[Sql.Function("SqlServer", "CHARINDEX", ServerSideOnly = true)]
public static int? CharIndex(string? expressionToFind, string? expressionToSearch, int? start_location)
Parameters
expressionToFind
stringA character expression containing the sequence to find.
expressionToFind
has an 8000 character limit.expressionToSearch
stringA character expression to search.
start_location
int?An integer or bigint expression at which the search starts. If
start_location
is not specified, has a negative value, or has a zero (0) value, the search starts at the beginning ofexpressionToSearch
.
Returns
- int?
bigint if
expressionToSearch
has an nvarchar(max), varbinary(max), or varchar(max) data type; int otherwise.
Exceptions
CharIndex(string?, string?, long?)
This function searches for one character expression inside a second character expression, returning the starting position of the first expression if found.
[Sql.Function("SqlServer", "CHARINDEX", ServerSideOnly = true)]
public static long? CharIndex(string? expressionToFind, string? expressionToSearch, long? start_location)
Parameters
expressionToFind
stringA character expression containing the sequence to find.
expressionToFind
has an 8000 character limit.expressionToSearch
stringA character expression to search.
start_location
long?An integer or bigint expression at which the search starts. If
start_location
is not specified, has a negative value, or has a zero (0) value, the search starts at the beginning ofexpressionToSearch
.
Returns
- long?
bigint if
expressionToSearch
has an nvarchar(max), varbinary(max), or varchar(max) data type; int otherwise.
Exceptions
CharIndexBig(string?, string?)
This function searches for one character expression inside a second character expression, returning the starting position of the first expression if found.
[Sql.Function("SqlServer", "CHARINDEX", ServerSideOnly = true)]
public static long? CharIndexBig(string? expressionToFind, string? expressionToSearch)
Parameters
expressionToFind
stringA character expression containing the sequence to find.
expressionToFind
has an 8000 character limit.expressionToSearch
stringA character expression to search.
Returns
- long?
bigint if
expressionToSearch
has an nvarchar(max), varbinary(max), or varchar(max) data type; int otherwise.
Exceptions
CharIndexBig(string?, string?, int?)
This function searches for one character expression inside a second character expression, returning the starting position of the first expression if found.
[Sql.Function("SqlServer", "CHARINDEX", ServerSideOnly = true)]
public static long? CharIndexBig(string? expressionToFind, string? expressionToSearch, int? start_location)
Parameters
expressionToFind
stringA character expression containing the sequence to find.
expressionToFind
has an 8000 character limit.expressionToSearch
stringA character expression to search.
start_location
int?An integer or bigint expression at which the search starts. If
start_location
is not specified, has a negative value, or has a zero (0) value, the search starts at the beginning ofexpressionToSearch
.
Returns
- long?
bigint if
expressionToSearch
has an nvarchar(max), varbinary(max), or varchar(max) data type; int otherwise.
Exceptions
CheckSum()
The CHECKSUM
function returns the checksum value computed over a table row, or over an expression list.
Use CHECKSUM
to build hash indexes.
[Sql.Expression("SqlServer", "CHECKSUM(*)", ServerSideOnly = true)]
public static int CheckSum()
Returns
- int
int
Exceptions
CheckSum(params object[])
The CHECKSUM
function returns the checksum value computed over a table row, or over an expression list.
Use CHECKSUM
to build hash indexes.
[Sql.Function("SqlServer", "CHECKSUM", ServerSideOnly = true)]
public static int CheckSum(params object[] expressions)
Parameters
expressions
object[]An expression of any type, except a noncomparable data type.
Returns
- int
int
Exceptions
Choose<T>(int?, params T[])
Returns the last identity value generated for a specified table or view. The last identity value generated can be for any session and any scope.
[Sql.Function("SqlServer", "CHOOSE", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Choose<T>(int? index, params T[] values)
Parameters
index
int?Is an integer expression that represents a 1-based index into the list of the items following it.
values
T[]List of comma separated values of any data type.
Returns
- T
Returns the data type with the highest precedence from the set of types passed to the function.
Type Parameters
T
Exceptions
Collate(string?, string)
Returns a character expression after converting uppercase character data to lowercase.
Windows_collation_name is the collation name for a Windows Collation Name.
Collation and Unicode support[Sql.Extension("SqlServer", "{string} COLLATE {collation_name}", ServerSideOnly = true, BuilderType = typeof(SqlFn.CollateBuilder))]
public static string? Collate(string? @string, string collation_name)
Parameters
string
stringcollation_name
stringIs the name of the collation to be applied to the expression, column definition, or database definition.
collation_name
can be only a specifiedWindows_collation_name
or aSQL_collation_name
.collation_name
must be a literal value.collation_name
cannot be represented by a variable or expression.
Returns
Exceptions
ColumnLength(string, string)
This function returns the defined length of a column, in bytes.
[Sql.Function("SqlServer", "COL_LENGTH", ServerSideOnly = true)]
public static short? ColumnLength(string table, string column)
Parameters
table
stringThe name of the table whose column length information we want to determine.
table
is an expression of type nvarchar.column
stringThe column name whose length we want to determine.
column
is an expression of type nvarchar.
Returns
- short?
smallint
Exceptions
ColumnName(int?, int)
This function returns the name of a table column, based on the table identification number and column identification number values of that table column.
[Sql.Function("SqlServer", "COL_NAME", ServerSideOnly = true)]
public static string? ColumnName(int? table_id, int column_id)
Parameters
table_id
int?The identification number of the table containing that column. The
table_id
argument has an int data type.column_id
intThe identification number of the column. The
column_id
argument has an int data type.
Returns
- string
sysname
Exceptions
ColumnProperty(int?, string, ColumnPropertyName)
This function returns column or parameter information.
[Sql.Extension("SqlServer", "COLUMNPROPERTY", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.ColumnPropertyName>))]
public static int? ColumnProperty(int? id, string column, SqlFn.ColumnPropertyName property)
Parameters
id
int?An expression containing the identifier (ID) of the table or procedure.
column
stringAn expression containing the name of the column or parameter.
property
SqlFn.ColumnPropertyNameFor the
id
argument, the property argument specifies the information type that theCOLUMNPROPERTY
function will return.
Returns
- int?
int
Exceptions
Compress(byte[]?)
This function compresses the input expression, using the GZIP algorithm. The function returns a byte array of type varbinary(max).
[Sql.Function("SqlServer", "COMPRESS", ServerSideOnly = true)]
public static byte[] Compress(byte[]? expression)
Parameters
expression
byte[]A
- binary(n)
- char(n)
- nchar(n)
- nvarchar(max)
- nvarchar(n)
- varbinary(max)
- varbinary(n)
- varchar(max)
- varchar(n)
Returns
- byte[]
varbinary(max) representing the compressed content of the input.
Exceptions
Compress(string?)
This function compresses the input expression, using the GZIP algorithm. The function returns a byte array of type varbinary(max).
[Sql.Function("SqlServer", "COMPRESS", ServerSideOnly = true)]
public static byte[] Compress(string? expression)
Parameters
expression
stringA
- binary(n)
- char(n)
- nchar(n)
- nvarchar(max)
- nvarchar(n)
- varbinary(max)
- varbinary(n)
- varchar(max)
- varchar(n)
Returns
- byte[]
varbinary(max) representing the compressed content of the input.
Exceptions
Concat(params string?[])
This function returns a string resulting from the concatenation, or joining, of two or more string values in an end-to-end manner.
[Sql.Function("SqlServer", "CONCAT", ServerSideOnly = true)]
public static string? Concat(params string?[] string_value)
Parameters
string_value
string[]A string value to concatenate to the other values. The
CONCAT
function requires at least twostring_value
arguments, and no more than 254string_value
arguments.
Returns
- string
string_value
Exceptions
ConcatWithSeparator(string?, params string?[])
This function returns a string resulting from the concatenation, or joining, of two or more string values in an end-to-end manner.
It separates those concatenated string values with the delimiter specified in the first function argument.
(CONCAT_WS
indicates concatenate with separator.)
[Sql.Function("SqlServer", "CONCAT_WS", ServerSideOnly = true)]
public static string? ConcatWithSeparator(string? separator, params string?[] arguments)
Parameters
separator
stringAn expression of any character type (
char
,nchar
,nvarchar
, orvarchar
).arguments
string[]An expression of any type. The
CONCAT_WS
function requires at least two arguments, and no more than 254 arguments.
Returns
- string
A string value whose length and type depend on the input.
Exceptions
ConnectionProperty(ConnectionPropertyName)
CONNECTIONPROPERTY (Transact-SQL)
For a request that comes in to the server, this function returns information about the connection properties of the unique connection which supports that request.
[Sql.Extension("SqlServer", "CONNECTIONPROPERTY", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.ConnectionPropertyName>))]
public static object? ConnectionProperty(SqlFn.ConnectionPropertyName property)
Parameters
property
SqlFn.ConnectionPropertyNameThe property of the connection.
Returns
- object
int
Exceptions
Convert<T>(SqlType<T>, object?)
CAST and CONVERT (Transact-SQL)
These functions convert an expression of one data type to another.
[Sql.Extension("SqlServer", "CONVERT({data_type}, {expression})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T Convert<T>(SqlType<T> data_type, object? expression)
Parameters
data_type
SqlType<T>The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.
expression
objectAny valid expression.
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
Convert<T>(SqlType<T>, object?, int)
CAST and CONVERT (Transact-SQL)
These functions convert an expression of one data type to another.
[Sql.Extension("SqlServer", "CONVERT({data_type}, {expression}, {style})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T Convert<T>(SqlType<T> data_type, object? expression, int style)
Parameters
data_type
SqlType<T>The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.
expression
objectAny valid expression.
style
int
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
Convert<T>(Func<SqlType<T>>, object?)
CAST and CONVERT (Transact-SQL)
These functions convert an expression of one data type to another.
[Sql.Extension("SqlServer", "CONVERT({data_type}, {expression})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T Convert<T>(Func<SqlType<T>> data_type, object? expression)
Parameters
data_type
Func<SqlType<T>>The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.
expression
objectAny valid expression.
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
Convert<T>(Func<SqlType<T>>, object?, int)
CAST and CONVERT (Transact-SQL)
These functions convert an expression of one data type to another.
[Sql.Extension("SqlServer", "CONVERT({data_type}, {expression}, {style})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T Convert<T>(Func<SqlType<T>> data_type, object? expression, int style)
Parameters
data_type
Func<SqlType<T>>The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.
expression
objectAny valid expression.
style
int
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
Convert<T>(object?)
CAST and CONVERT (Transact-SQL)
These functions convert an expression of one data type to another.
[Sql.Expression("SqlServer", "CONVERT({1}, {0})", ServerSideOnly = true)]
public static T Convert<T>(object? expression)
Parameters
expression
objectAny valid expression.
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
Convert<T>(object?, int)
CAST and CONVERT (Transact-SQL)
These functions convert an expression of one data type to another.
[Sql.Expression("SqlServer", "CONVERT({2}, {0}, {1})", ServerSideOnly = true)]
public static T Convert<T>(object? expression, int style)
Parameters
expression
objectAny valid expression.
style
int
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
Cos<T>(T)
A mathematical function that returns the trigonometric cosine of the specified angle - measured in radians - in the specified expression.
[Sql.Function("SqlServer", "COS", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Cos<T>(T float_expression)
Parameters
float_expression
TAn expression of type float.
Returns
- T
float
Type Parameters
T
Exceptions
Cot<T>(T)
A mathematical function that returns the trigonometric cotangent of the specified angle - in radians - in the specified float expression.
[Sql.Function("SqlServer", "COT", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Cot<T>(T float_expression)
Parameters
float_expression
TAn expression of type float, or of a type that can implicitly convert to float.
Returns
- T
float
Type Parameters
T
Exceptions
CurrentRequestID()
CURRENT_REQUEST_ID (Transact-SQL)
This function returns the ID of the current request within the current session.
[Sql.Function("SqlServer", "CURRENT_REQUEST_ID", ServerSideOnly = true)]
public static short CurrentRequestID()
Returns
- short
smallint
Exceptions
CurrentTimezone()
CURRENT_TIMEZONE (Transact-SQL)
This function returns the name of the time zone observed by a server or an instance. For SQL Managed Instance, return value is based on the time zone of the instance itself assigned during instance creation, not the time zone of the underlying operating system.
[Sql.Function("SqlServer", "CURRENT_TIMEZONE", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static string CurrentTimezone()
Returns
- string
varchar
Exceptions
CurrentTimezoneID()
CURRENT_TIMEZONE_ID (Transact-SQL)
This function returns the ID of the time zone observed by a server or an instance. For Azure SQL Managed Instance, return value is based on the time zone of the instance itself assigned during instance creation, not the time zone of the underlying operating system.
[Sql.Function("SqlServer", "CURRENT_TIMEZONE_ID", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static string CurrentTimezoneID()
Returns
- string
varchar
Exceptions
CurrentTransactionID()
CURRENT_TRANSACTION_ID (Transact-SQL)
This function returns the transaction ID of the current transaction in the current session.
[Sql.Function("SqlServer", "CURRENT_TRANSACTION_ID", ServerSideOnly = true)]
public static long CurrentTransactionID()
Returns
- long
bigint
Exceptions
DataLengthBig<T>(T)
This function returns the number of bytes used to represent any expression.
DATALENGTH
becomes really helpful when used with data types that can store variable-length data, such as:
- ntext
- nvarchar
- text
- varbinary
- varchar
For a NULL value, DATALENGTH
returns NULL.
[Sql.Function("SqlServer", "DATALENGTH", new int[] { 0 }, ServerSideOnly = true)]
[CLSCompliant(false)]
public static long? DataLengthBig<T>(T expression)
Parameters
expression
TAn expression of any data type.
Returns
- long?
bigint if expression has an nvarchar(max), varbinary(max), or varchar(max) data type; otherwise int.
Type Parameters
T
An expression of any data type.
Exceptions
DataLength<T>(T)
This function returns the number of bytes used to represent any expression.
DATALENGTH
becomes really helpful when used with data types that can store variable-length data, such as:
- ntext
- nvarchar
- text
- varbinary
- varchar
For a NULL value, DATALENGTH
returns NULL.
[Sql.Function("SqlServer", "DATALENGTH", new int[] { 0 }, ServerSideOnly = true)]
[CLSCompliant(false)]
public static int? DataLength<T>(T expression)
Parameters
expression
TAn expression of any data type.
Returns
- int?
bigint if expression has an nvarchar(max), varbinary(max), or varchar(max) data type; otherwise int.
Type Parameters
T
An expression of any data type.
Exceptions
DatabasePropertyEx(string, DatabasePropertyName)
DATABASEPROPERTYEX (Transact-SQL)
For a specified database in SQL Server, this function returns the current setting of the specified database option or property.
[Sql.Extension("SqlServer", "DATABASEPROPERTYEX", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.DatabasePropertyName>))]
public static object? DatabasePropertyEx(string database, SqlFn.DatabasePropertyName property)
Parameters
database
stringAn expression specifying the name of the database for which
DATABASEPROPERTYEX
will return the named property information.database
has an nvarchar(128) data type.property
SqlFn.DatabasePropertyNameAn expression specifying the name of the database property to return.
property
has a varchar(128) data type
Returns
- object
sql_variant
Exceptions
DateAdd(DateParts, int?, DateTimeOffset?)
This function adds a number (a signed integer) to a datepart of an input date, and returns a modified date/time value.
[Sql.Extension("SqlServer", "DATEADD({datepart}, {number}, {date})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static DateTimeOffset? DateAdd(SqlFn.DateParts datepart, int? number, DateTimeOffset? date)
Parameters
datepart
SqlFn.DatePartsThe part of date to which
DATEADD
adds an integer number. This table lists all valid datepart arguments.number
int?An expression that can resolve to an int that
DATEADD
adds to a datepart of date.DATEADD
accepts user-defined variable values for number.DATEADD
will truncate a specified number value that has a decimal fraction. It will not round the number value in this situation.date
DateTimeOffset?
Returns
- DateTimeOffset?
varchar
Exceptions
DateAdd(DateParts, int?, DateTime?)
This function adds a number (a signed integer) to a datepart of an input date, and returns a modified date/time value.
[Sql.Extension("SqlServer", "DATEADD({datepart}, {number}, {date})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static DateTime? DateAdd(SqlFn.DateParts datepart, int? number, DateTime? date)
Parameters
datepart
SqlFn.DatePartsThe part of date to which
DATEADD
adds an integer number. This table lists all valid datepart arguments.number
int?An expression that can resolve to an int that
DATEADD
adds to a datepart of date.DATEADD
accepts user-defined variable values for number.DATEADD
will truncate a specified number value that has a decimal fraction. It will not round the number value in this situation.date
DateTime?
Returns
- DateTime?
varchar
Exceptions
DateAdd(DateParts, int?, TimeSpan?)
This function adds a number (a signed integer) to a datepart of an input date, and returns a modified date/time value.
[Sql.Extension("SqlServer", "DATEADD({datepart}, {number}, {date})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static TimeSpan? DateAdd(SqlFn.DateParts datepart, int? number, TimeSpan? date)
Parameters
datepart
SqlFn.DatePartsThe part of date to which
DATEADD
adds an integer number. This table lists all valid datepart arguments.number
int?An expression that can resolve to an int that
DATEADD
adds to a datepart of date.DATEADD
accepts user-defined variable values for number.DATEADD
will truncate a specified number value that has a decimal fraction. It will not round the number value in this situation.date
TimeSpan?
Returns
- TimeSpan?
varchar
Exceptions
DateAdd(DateParts, int?, string?)
This function adds a number (a signed integer) to a datepart of an input date, and returns a modified date/time value.
[Sql.Extension("SqlServer", "DATEADD({datepart}, {number}, {date})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static DateTime? DateAdd(SqlFn.DateParts datepart, int? number, string? date)
Parameters
datepart
SqlFn.DatePartsThe part of date to which
DATEADD
adds an integer number. This table lists all valid datepart arguments.number
int?An expression that can resolve to an int that
DATEADD
adds to a datepart of date.DATEADD
accepts user-defined variable values for number.DATEADD
will truncate a specified number value that has a decimal fraction. It will not round the number value in this situation.date
string
Returns
- DateTime?
varchar
Exceptions
DateDiff(DateParts, DateTimeOffset?, DateTimeOffset?)
This function returns the count (as a signed integer value) of the specified datepart boundaries crossed
between the specified startdate
and enddate
.
[Sql.Extension("SqlServer", "DATEDIFF({datepart}, {startdate}, {enddate})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static int? DateDiff(SqlFn.DateParts datepart, DateTimeOffset? startdate, DateTimeOffset? enddate)
Parameters
datepart
SqlFn.DatePartsstartdate
DateTimeOffset?enddate
DateTimeOffset?
Returns
- int?
int
Exceptions
DateDiff(DateParts, DateTime?, DateTime?)
This function returns the count (as a signed integer value) of the specified datepart boundaries crossed
between the specified startdate
and enddate
.
[Sql.Extension("SqlServer", "DATEDIFF({datepart}, {startdate}, {enddate})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static int? DateDiff(SqlFn.DateParts datepart, DateTime? startdate, DateTime? enddate)
Parameters
Returns
- int?
int
Exceptions
DateDiff(DateParts, TimeSpan?, TimeSpan?)
This function returns the count (as a signed integer value) of the specified datepart boundaries crossed
between the specified startdate
and enddate
.
[Sql.Extension("SqlServer", "DATEDIFF({datepart}, {startdate}, {enddate})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static int? DateDiff(SqlFn.DateParts datepart, TimeSpan? startdate, TimeSpan? enddate)
Parameters
Returns
- int?
int
Exceptions
DateDiff(DateParts, string?, string?)
This function returns the count (as a signed integer value) of the specified datepart boundaries crossed
between the specified startdate
and enddate
.
[Sql.Extension("SqlServer", "DATEDIFF({datepart}, {startdate}, {enddate})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static int? DateDiff(SqlFn.DateParts datepart, string? startdate, string? enddate)
Parameters
Returns
- int?
int
Exceptions
DateDiffBig(DateParts, DateTimeOffset?, DateTimeOffset?)
This function returns the count (as a signed integer value) of the specified datepart boundaries crossed
between the specified startdate
and enddate
.
[Sql.Extension("SqlServer", "DATEDIFF_BIG({datepart}, {startdate}, {enddate})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static long? DateDiffBig(SqlFn.DateParts datepart, DateTimeOffset? startdate, DateTimeOffset? enddate)
Parameters
datepart
SqlFn.DatePartsstartdate
DateTimeOffset?enddate
DateTimeOffset?
Returns
- long?
bigint
Exceptions
DateDiffBig(DateParts, DateTime?, DateTime?)
This function returns the count (as a signed integer value) of the specified datepart boundaries crossed
between the specified startdate
and enddate
.
[Sql.Extension("SqlServer", "DATEDIFF_BIG({datepart}, {startdate}, {enddate})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static long? DateDiffBig(SqlFn.DateParts datepart, DateTime? startdate, DateTime? enddate)
Parameters
Returns
- long?
bigint
Exceptions
DateDiffBig(DateParts, TimeSpan?, TimeSpan?)
This function returns the count (as a signed integer value) of the specified datepart boundaries crossed
between the specified startdate
and enddate
.
[Sql.Extension("SqlServer", "DATEDIFF_BIG({datepart}, {startdate}, {enddate})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static long? DateDiffBig(SqlFn.DateParts datepart, TimeSpan? startdate, TimeSpan? enddate)
Parameters
Returns
- long?
bigint
Exceptions
DateDiffBig(DateParts, string?, string?)
This function returns the count (as a signed integer value) of the specified datepart boundaries crossed
between the specified startdate
and enddate
.
[Sql.Extension("SqlServer", "DATEDIFF_BIG({datepart}, {startdate}, {enddate})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static long? DateDiffBig(SqlFn.DateParts datepart, string? startdate, string? enddate)
Parameters
Returns
- long?
bigint
Exceptions
DateFromParts(int?, int?, int?)
This function returns a date value that maps to the specified year, month, and day values.
[Sql.Function("SqlServer", "DATEFROMPARTS", ServerSideOnly = true)]
public static DateTime? DateFromParts(int? year, int? month, int? day)
Parameters
year
int?An integer expression that specifies a year.
month
int?An integer expression that specifies a month, from 1 to 12.
day
int?An integer expression that specifies a day.
Returns
- DateTime?
date
Exceptions
DateName(DateParts, DateTimeOffset?)
This function returns a character string representing the specified datepart of the specified date
.
[Sql.Extension("SqlServer", "DATENAME({datepart}, {date})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static string? DateName(SqlFn.DateParts datepart, DateTimeOffset? date)
Parameters
datepart
SqlFn.DatePartsThe specific part of the date argument that
DATENAME
will return. This table lists all valid datepart arguments.date
DateTimeOffset?
Returns
- string
nvarchar
Exceptions
DateName(DateParts, DateTime?)
This function returns a character string representing the specified datepart of the specified date
.
[Sql.Extension("SqlServer", "DATENAME({datepart}, {date})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static string? DateName(SqlFn.DateParts datepart, DateTime? date)
Parameters
datepart
SqlFn.DatePartsThe specific part of the date argument that
DATENAME
will return. This table lists all valid datepart arguments.date
DateTime?
Returns
- string
nvarchar
Exceptions
DateName(DateParts, TimeSpan?)
This function returns a character string representing the specified datepart of the specified date
.
[Sql.Extension("SqlServer", "DATENAME({datepart}, {date})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static string? DateName(SqlFn.DateParts datepart, TimeSpan? date)
Parameters
datepart
SqlFn.DatePartsThe specific part of the date argument that
DATENAME
will return. This table lists all valid datepart arguments.date
TimeSpan?
Returns
- string
nvarchar
Exceptions
DateName(DateParts, string?)
This function returns a character string representing the specified datepart of the specified date
.
[Sql.Extension("SqlServer", "DATENAME({datepart}, {date})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static string? DateName(SqlFn.DateParts datepart, string? date)
Parameters
datepart
SqlFn.DatePartsThe specific part of the date argument that
DATENAME
will return. This table lists all valid datepart arguments.date
string
Returns
- string
nvarchar
Exceptions
DatePart(DateParts, DateTimeOffset?)
This function returns an integer representing the specified datepart
of the specified date
.
[Sql.Extension("SqlServer", "DATEPART({datepart}, {date})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static int? DatePart(SqlFn.DateParts datepart, DateTimeOffset? date)
Parameters
datepart
SqlFn.DatePartsThe specific part of the date argument for which
DATEPART
will return an integer. This table lists all valid datepart arguments.date
DateTimeOffset?
Returns
- int?
int
Exceptions
DatePart(DateParts, DateTime?)
This function returns an integer representing the specified datepart
of the specified date
.
[Sql.Extension("SqlServer", "DATEPART({datepart}, {date})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static int? DatePart(SqlFn.DateParts datepart, DateTime? date)
Parameters
datepart
SqlFn.DatePartsThe specific part of the date argument for which
DATEPART
will return an integer. This table lists all valid datepart arguments.date
DateTime?
Returns
- int?
int
Exceptions
DatePart(DateParts, TimeSpan?)
This function returns an integer representing the specified datepart
of the specified date
.
[Sql.Extension("SqlServer", "DATEPART({datepart}, {date})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static int? DatePart(SqlFn.DateParts datepart, TimeSpan? date)
Parameters
datepart
SqlFn.DatePartsThe specific part of the date argument for which
DATEPART
will return an integer. This table lists all valid datepart arguments.date
TimeSpan?
Returns
- int?
int
Exceptions
DatePart(DateParts, string?)
This function returns an integer representing the specified datepart
of the specified date
.
[Sql.Extension("SqlServer", "DATEPART({datepart}, {date})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DatePartBuilder))]
public static int? DatePart(SqlFn.DateParts datepart, string? date)
Parameters
datepart
SqlFn.DatePartsThe specific part of the date argument for which
DATEPART
will return an integer. This table lists all valid datepart arguments.date
string
Returns
- int?
int
Exceptions
DateTime2FromParts(int?, int?, int?)
DATETIME2FROMPARTS (Transact-SQL)
This function returns a datetime2 value for the specified date and time arguments.
[Sql.Expression("SqlServer", "DATETIME2FROMPARTS({0}, {1}, {2}, 0, 0, 0, 0, 0)", ServerSideOnly = true)]
public static DateTime? DateTime2FromParts(int? year, int? month, int? day)
Parameters
Returns
- DateTime?
datetime2
Exceptions
DateTime2FromParts(int?, int?, int?, int?, int?, int?)
DATETIME2FROMPARTS (Transact-SQL)
This function returns a datetime2 value for the specified date and time arguments.
[Sql.Expression("SqlServer", "DATETIME2FROMPARTS({0}, {1}, {2}, {3}, {4}, {5}, 0, 0)", ServerSideOnly = true)]
public static DateTime? DateTime2FromParts(int? year, int? month, int? day, int? hour, int? minute, int? seconds)
Parameters
Returns
- DateTime?
datetime2
Exceptions
DateTime2FromParts(int?, int?, int?, int?, int?, int?, int?, int?)
DATETIME2FROMPARTS (Transact-SQL)
This function returns a datetime2 value for the specified date and time arguments.
[Sql.Function("SqlServer", "DATETIME2FROMPARTS", ServerSideOnly = true)]
public static DateTime? DateTime2FromParts(int? year, int? month, int? day, int? hour, int? minute, int? seconds, int? fractions, int? precision)
Parameters
Returns
- DateTime?
datetime2
Exceptions
DateTimeFromParts(int?, int?, int?)
DATETIMEFROMPARTS (Transact-SQL)
This function returns a datetime value for the specified date and time arguments.
[Sql.Expression("SqlServer", "DATETIMEFROMPARTS({0}, {1}, {2}, 0, 0, 0, 0)", ServerSideOnly = true)]
public static DateTime? DateTimeFromParts(int? year, int? month, int? day)
Parameters
Returns
- DateTime?
datetime
Exceptions
DateTimeFromParts(int?, int?, int?, int?, int?, int?)
DATETIMEFROMPARTS (Transact-SQL)
This function returns a datetime value for the specified date and time arguments.
[Sql.Expression("SqlServer", "DATETIMEFROMPARTS({0}, {1}, {2}, {3}, {4}, {5}, 0)", ServerSideOnly = true)]
public static DateTime? DateTimeFromParts(int? year, int? month, int? day, int? hour, int? minute, int? seconds)
Parameters
Returns
- DateTime?
datetime
Exceptions
DateTimeFromParts(int?, int?, int?, int?, int?, int?, int?)
DATETIMEFROMPARTS (Transact-SQL)
This function returns a datetime value for the specified date and time arguments.
[Sql.Function("SqlServer", "DATETIMEFROMPARTS", ServerSideOnly = true)]
public static DateTime? DateTimeFromParts(int? year, int? month, int? day, int? hour, int? minute, int? seconds, int? milliseconds)
Parameters
Returns
- DateTime?
datetime
Exceptions
DateTimeOffsetFromParts(int?, int?, int?)
DATETIMEOFFSETFROMPARTS (Transact-SQL)
Returns a datetimeoffset value for the specified date and time arguments. The returned value has a precision specified by the precision argument, and an offset as specified by the offset arguments.
[Sql.Expression("SqlServer", "DATETIMEOFFSETFROMPARTS({0}, {1}, {2}, 0, 0, 0, 0, 0, 0, 0)", ServerSideOnly = true)]
public static DateTimeOffset? DateTimeOffsetFromParts(int? year, int? month, int? day)
Parameters
Returns
- DateTimeOffset?
datetimeoffset
Exceptions
DateTimeOffsetFromParts(int?, int?, int?, int?, int?, int?)
DATETIMEOFFSETFROMPARTS (Transact-SQL)
Returns a datetimeoffset value for the specified date and time arguments. The returned value has a precision specified by the precision argument, and an offset as specified by the offset arguments.
[Sql.Expression("SqlServer", "DATETIMEOFFSETFROMPARTS({0}, {1}, {2}, {3}, {4}, {5}, 0, 0, 0, 0)", ServerSideOnly = true)]
public static DateTimeOffset? DateTimeOffsetFromParts(int? year, int? month, int? day, int? hour, int? minute, int? seconds)
Parameters
Returns
- DateTimeOffset?
datetimeoffset
Exceptions
DateTimeOffsetFromParts(int?, int?, int?, int?, int?, int?, int?, int?, int?, int?)
DATETIMEOFFSETFROMPARTS (Transact-SQL)
Returns a datetimeoffset value for the specified date and time arguments. The returned value has a precision specified by the precision argument, and an offset as specified by the offset arguments.
[Sql.Function("SqlServer", "DATETIMEOFFSETFROMPARTS", ServerSideOnly = true)]
public static DateTimeOffset? DateTimeOffsetFromParts(int? year, int? month, int? day, int? hour, int? minute, int? seconds, int? fractions, int? hour_offset, int? minute_offset, int? precision)
Parameters
year
int?month
int?day
int?hour
int?minute
int?seconds
int?fractions
int?hour_offset
int?minute_offset
int?precision
int?
Returns
- DateTimeOffset?
datetimeoffset
Exceptions
Day(DateTimeOffset?)
This function returns an integer that represents the day (day of the month) of the specified date
.
[Sql.Function("SqlServer", "DAY", ServerSideOnly = true)]
public static int? Day(DateTimeOffset? date)
Parameters
date
DateTimeOffset?
Returns
- int?
int
Exceptions
Day(DateTime?)
This function returns an integer that represents the day (day of the month) of the specified date
.
[Sql.Function("SqlServer", "DAY", ServerSideOnly = true)]
public static int? Day(DateTime? date)
Parameters
date
DateTime?
Returns
- int?
int
Exceptions
Day(string?)
This function returns an integer that represents the day (day of the month) of the specified date
.
[Sql.Function("SqlServer", "DAY", ServerSideOnly = true)]
public static int? Day(string? date)
Parameters
date
string
Returns
- int?
int
Exceptions
DbID()
This function returns the database identification (ID) number of a specified database.
[Sql.Function("SqlServer", "DB_ID", ServerSideOnly = true)]
public static int DbID()
Returns
- int
int
Exceptions
DbID(string)
This function returns the database identification (ID) number of a specified database.
[Sql.Function("SqlServer", "DB_ID", ServerSideOnly = true)]
public static int? DbID(string database_name)
Parameters
database_name
stringThe name of the database whose database ID number
DB_ID
will return. If the call toDB_ID
omitsdatabase_name
,DB_ID
returns the ID of the current database.
Returns
- int?
int
Exceptions
DbName()
This function returns the name of a specified database.
[Sql.Function("SqlServer", "DB_NAME", ServerSideOnly = true)]
public static string DbName()
Returns
- string
nvarchar(128)
Exceptions
DbName(int)
This function returns the name of a specified database.
[Sql.Function("SqlServer", "DB_NAME", ServerSideOnly = true)]
public static string? DbName(int database_id)
Parameters
database_id
intThe identification number (ID) of the database whose name
DB_NAME
will return. If the call toDB_NAME
omitsdatabase_id
,DB_NAME
returns the name of the current database.
Returns
- string
nvarchar(128)
Exceptions
Decompress(byte[])
This function will decompress an input expression value, using the GZIP algorithm.
DECOMPRESS
will return a byte array (VARBINARY(MAX) type).
[Sql.Function("SqlServer", "DECOMPRESS", ServerSideOnly = true)]
public static byte[] Decompress(byte[] expression)
Parameters
expression
byte[]A varbinary(n), varbinary(max), or binary(n) value.
Returns
- byte[]
varbinary(max) representing the compressed content of the input.
Exceptions
Degrees<T>(T)
This function returns the corresponding angle, in degrees, for an angle specified in radians.
[Sql.Function("SqlServer", "DEGREES", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Degrees<T>(T numeric_expression)
Parameters
numeric_expression
TAn expression of the exact numeric or approximate numeric data type category, except for the bit data type.
Returns
- T
Return values have the same type as
numeric_expression
.
Type Parameters
T
Exceptions
Difference(string?, string?)
This function returns an integer value measuring the difference between the SOUNDEX() values of two different character expressions.
[Sql.Function("SqlServer", "DIFFERENCE", ServerSideOnly = true)]
public static int? Difference(string? character_expression1, string? character_expression2)
Parameters
character_expression1
stringAn alphanumeric expression of character data.
character_expression
can be a constant, variable, or column.character_expression2
string
Returns
- int?
int
Exceptions
EndOfMonth(DateTime?)
This function returns the last day of the month containing a specified date, with an optional offset.
[Sql.Function("SqlServer", "EOMONTH", ServerSideOnly = true)]
public static DateTime? EndOfMonth(DateTime? start_date)
Parameters
start_date
DateTime?A date expression that specifies the date for which to return the last day of the month.
Returns
- DateTime?
date
Exceptions
EndOfMonth(DateTime?, int?)
This function returns the last day of the month containing a specified date, with an optional offset.
[Sql.Function("SqlServer", "EOMONTH", ServerSideOnly = true)]
public static DateTime? EndOfMonth(DateTime? start_date, int? month_to_add)
Parameters
start_date
DateTime?A date expression that specifies the date for which to return the last day of the month.
month_to_add
int?An optional integer expression that specifies the number of months to add to
start_date
.
Returns
- DateTime?
date
Exceptions
EndOfMonth(string?)
This function returns the last day of the month containing a specified date, with an optional offset.
[Sql.Function("SqlServer", "EOMONTH", ServerSideOnly = true)]
public static DateTime? EndOfMonth(string? start_date)
Parameters
start_date
stringA date expression that specifies the date for which to return the last day of the month.
Returns
- DateTime?
date
Exceptions
EndOfMonth(string?, int?)
This function returns the last day of the month containing a specified date, with an optional offset.
[Sql.Function("SqlServer", "EOMONTH", ServerSideOnly = true)]
public static DateTime? EndOfMonth(string? start_date, int? month_to_add)
Parameters
start_date
stringA date expression that specifies the date for which to return the last day of the month.
month_to_add
int?An optional integer expression that specifies the number of months to add to
start_date
.
Returns
- DateTime?
date
Exceptions
Exp<T>(T)
Returns the exponential value of the specified float expression.
[Sql.Function("SqlServer", "EXP", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Exp<T>(T float_expression)
Parameters
float_expression
TIs an expression of type float or of a type that can be implicitly converted to float.
Returns
- T
float
Type Parameters
T
Exceptions
FileGroupID(string?)
This function returns the filegroup identification (ID) number for a specified filegroup name.
[Sql.Function("SqlServer", "FILEGROUP_ID", ServerSideOnly = true)]
public static int? FileGroupID(string? filegroup_name)
Parameters
filegroup_name
stringAn expression of type sysname, representing the filegroup name whose filegroup ID
FILEGROUP_ID
will return.
Returns
- int?
int
Exceptions
FileGroupName(short?)
This function returns the filegroup name for the specified filegroup identification (ID) number.
[Sql.Function("SqlServer", "FILEGROUP_Name", ServerSideOnly = true)]
public static string? FileGroupName(short? filegroup_id)
Parameters
filegroup_id
short?The filegroup ID number whose filegroup name
FILEGROUP_NAME
will return. filegroup_id has a smallint data type.
Returns
- string
nvarchar(128)
Exceptions
FileGroupProperty(string?, FileGroupPropertyName)
FILEGROUPPROPERTY (Transact-SQL)
This function returns the filegroup property value for a specified name and filegroup value.
[Sql.Extension("SqlServer", "FILEGROUPPROPERTY", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.FileGroupPropertyName>))]
public static int? FileGroupProperty(string? filegroup_name, SqlFn.FileGroupPropertyName property)
Parameters
filegroup_name
stringAn expression of type sysname that represents the filegroup name for which
FILEGROUPPROPERTY
returns the named property information.property
SqlFn.FileGroupPropertyNameAn expression of type varchar(128) that returns the name of the filegroup property.
Returns
- int?
int
Exceptions
FileID(string?)
For the given logical name for a component file of the current database, this function returns the file identification (ID) number.
[Sql.Function("SqlServer", "FILE_ID", ServerSideOnly = true)]
public static short? FileID(string? file_name)
Parameters
file_name
stringAn expression of type sysname, representing the logical name of the file whose file ID value
FILE_ID
will return.
Returns
- short?
smallint
Exceptions
FileIDEx(string?)
This function returns the file identification (ID) number for the specified logical name of a data, log, or full-text file of the current database.
[Sql.Function("SqlServer", "FILE_IDEX", ServerSideOnly = true)]
public static int? FileIDEx(string? file_name)
Parameters
file_name
stringAn expression of type sysname that returns the file ID value 'FILE_IDEX' for the name of the file.
Returns
- int?
int
Exceptions
FileName(int?)
This function returns the logical file name for a given file identification (ID) number.
[Sql.Function("SqlServer", "FILE_NAME", ServerSideOnly = true)]
public static string? FileName(int? file_id)
Parameters
file_id
int?The file identification number whose file name
FILE_NAME
will return. file_id has an int data type.
Returns
- string
nvarchar(128)
Exceptions
FileProperty(string?, FilePropertyName)
Returns the specified file name property value when a file name in the current database and a property name are specified. Returns NULL for files that are not in the current database.
[Sql.Extension("SqlServer", "FILEPROPERTY", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.FilePropertyName>))]
public static int? FileProperty(string? file_name, SqlFn.FilePropertyName property)
Parameters
file_name
stringIs an expression that contains the name of the file associated with the current database for which to return property information.
file_name
is nchar(128).property
SqlFn.FilePropertyNameIs an expression that contains the name of the file property to return.
property
is varchar(128), and can be one of the following values.
Returns
- int?
int
Exceptions
FilePropertyEx(string?, FilePropertyExName)
Returns the specified extended file property value when a file name in the current database and a property name are specified. Returns NULL for files that are not in the current database or for extended file properties that do not exist. Currently, extended file properties only apply to databases that are in Azure Blob storage.
[Sql.Extension("SqlServer", "FILEPROPERTYEX", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.FilePropertyExName>))]
public static object? FilePropertyEx(string? file_name, SqlFn.FilePropertyExName property)
Parameters
file_name
stringIs an expression that contains the name of the file associated with the current database for which to return property information.
file_name
is nchar(128).property
SqlFn.FilePropertyExNameIs an expression that contains the name of the file property to return.
property
is varchar(128), and can be one of the following values.
Returns
- object
sql_variant
Exceptions
Floor<T>(T)
Returns the largest integer less than or equal to the specified numeric expression.
[Sql.Function("SqlServer", "FLOOR", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Floor<T>(T numeric_expression)
Parameters
numeric_expression
TAn expression of the exact numeric or approximate numeric data type category, except for the bit data type.
Returns
- T
Return values have the same type as
numeric_expression
.
Type Parameters
T
Exceptions
Format(object?, string?)
Returns a value formatted with the specified format and optional culture. Use the FORMAT function for locale-aware formatting of date/time and number values as strings. For general data type conversions, use CAST or CONVERT.
[Sql.Function("SqlServer", "FORMAT", ServerSideOnly = true)]
public static string? Format(object? value, string? format)
Parameters
value
objectExpression of a supported data type to format. For a list of valid types, see the table in the following Remarks section.
format
string
Returns
- string
nvarchar or null
Exceptions
FormatMessage(int, params object?[])
Constructs a message from an existing message in sys.messages or from a provided string. The functionality of FORMATMESSAGE resembles that of the RAISERROR statement. However, RAISERROR prints the message immediately, while FORMATMESSAGE returns the formatted message for further processing.
[Sql.Function("SqlServer", "FORMATMESSAGE", ServerSideOnly = true)]
public static string? FormatMessage(int msg_number, params object?[] param_values)
Parameters
msg_number
intIs the ID of the message stored in sys.messages. If msg_number is <= 13000, or if the message does not exist in sys.messages, NULL is returned.
param_values
object[]Is a parameter value for use in the message. Can be more than one parameter value. The values must be specified in the order in which the placeholder variables appear in the message. The maximum number of values is 20.
Returns
- string
nvarchar
Exceptions
FormatMessage(string, params object?[])
Constructs a message from an existing message in sys.messages or from a provided string. The functionality of FORMATMESSAGE resembles that of the RAISERROR statement. However, RAISERROR prints the message immediately, while FORMATMESSAGE returns the formatted message for further processing.
[Sql.Function("SqlServer", "FORMATMESSAGE", ServerSideOnly = true)]
public static string? FormatMessage(string msg_string, params object?[] param_values)
Parameters
msg_string
stringIs a string enclosed in single quotes and containing parameter value placeholders. The error message can have a maximum of 2,047 characters. If the message contains 2,048 or more characters, only the first 2,044 are displayed and an ellipsis is added to indicate that the message has been truncated. Note that substitution parameters consume more characters than the output shows because of internal storage behavior.
param_values
object[]Is a parameter value for use in the message. Can be more than one parameter value. The values must be specified in the order in which the placeholder variables appear in the message. The maximum number of values is 20.
Returns
- string
nvarchar
Exceptions
FullTextCatalogProperty(string?, FullTextCatalogPropertyName)
FULLTEXTCATALOGPROPERTY (Transact-SQL)
Returns information about full-text catalog properties in SQL Server.
[Sql.Extension("SqlServer", "FULLTEXTCATALOGPROPERTY", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.FullTextCatalogPropertyName>))]
public static int? FullTextCatalogProperty(string? catalog_name, SqlFn.FullTextCatalogPropertyName property)
Parameters
catalog_name
stringIs an expression containing the name of the full-text catalog.
property
SqlFn.FullTextCatalogPropertyNameIs an expression containing the name of the full-text catalog property. The table lists the properties and provides descriptions of the information returned.
Returns
- int?
int
Exceptions
FullTextServiceProperty(FullTextServicePropertyName)
FULLTEXTSERVICEPROPERTY (Transact-SQL)
Returns information related to the properties of the Full-Text Engine. These properties can be set and retrieved by using sp_fulltext_service.
[Sql.Extension("SqlServer", "FULLTEXTSERVICEPROPERTY", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.FullTextServicePropertyName>))]
public static int? FullTextServiceProperty(SqlFn.FullTextServicePropertyName property)
Parameters
property
SqlFn.FullTextServicePropertyNameIs an expression containing the name of the full-text service-level property. The table lists the properties and provides descriptions of the information returned.
Returns
- int?
int
Exceptions
GetAnsiNull()
Returns the default nullability for the database for this session.
[Sql.Function("SqlServer", "GETANSINULL", ServerSideOnly = true)]
public static int? GetAnsiNull()
Returns
- int?
int
Exceptions
GetAnsiNull(string)
Returns the default nullability for the database for this session.
[Sql.Function("SqlServer", "GETANSINULL", ServerSideOnly = true)]
public static int? GetAnsiNull(string database)
Parameters
database
stringIs the name of the database for which to return nullability information.
database
is either char or nchar. If char,database
is implicitly converted to nchar.
Returns
- int?
int
Exceptions
GetDate()
Returns the current database system timestamp as a datetime value without the database time zone offset.
[Sql.Function("SqlServer", "GETDATE", ServerSideOnly = true)]
public static DateTime GetDate()
Returns
- DateTime
datetime
Exceptions
GetUtcDate()
Returns the current database system timestamp as a datetime value. The database time zone offset is not included. This value represents the current UTC time (Coordinated Universal Time). This value is derived from the operating system of the computer on which the instance of SQL Server is running.
[Sql.Function("SqlServer", "GETUTCDATE", ServerSideOnly = true)]
public static DateTime GetUtcDate()
Returns
- DateTime
datetime
Exceptions
HostID()
Returns the workstation identification number. The workstation identification number is the process ID (PID) of the application on the client computer that is connecting to SQL Server.
[Sql.Function("SqlServer", "HOST_ID", ServerSideOnly = true)]
public static string HostID()
Returns
- string
char(10)
Exceptions
HostName()
Returns the workstation identification number. The workstation identification number is the process ID (PID) of the application on the client computer that is connecting to SQL Server.
[Sql.Function("SqlServer", "HOST_NAME", ServerSideOnly = true)]
public static string HostName()
Returns
- string
nvarchar(128)
Exceptions
IdentityCurrent(string)
Returns the last identity value generated for a specified table or view. The last identity value generated can be for any session and any scope.
[Sql.Function("SqlServer", "IDENT_CURRENT", ServerSideOnly = true)]
public static decimal IdentityCurrent(string table_or_view)
Parameters
table_or_view
stringIs the name of the table or view whose identity value is returned.
table_or_view
is varchar, with no default.
Returns
- decimal
numeric(@@MAXPRECISION, 0))
Exceptions
IdentityIncrement(string)
Returns the increment value specified when creating a table or view's identity column.
[Sql.Function("SqlServer", "IDENT_INCR", ServerSideOnly = true)]
public static decimal IdentityIncrement(string table_or_view)
Parameters
table_or_view
stringIs an expression specifying the table or view to check for a valid identity increment value.
table_or_view
can be a character string constant enclosed in quotation marks. It can also be a variable, a function, or a column name.table_or_view
is char, nchar, varchar, or nvarchar.
Returns
- decimal
numeric(@@MAXPRECISION, 0))
Exceptions
IdentitySeed(string)
Returns the original seed value specified when creating an identity column in a table or a view. Changing the current value of an identity column by using DBCC CHECKIDENT doesn't change the value returned by this function.
[Sql.Function("SqlServer", "IDENT_SEED", ServerSideOnly = true)]
public static decimal IdentitySeed(string table_or_view)
Parameters
table_or_view
stringIs an expression specifying the table or view to check for a valid identity increment value.
table_or_view
can be a character string constant enclosed in quotation marks. It can also be a variable, a function, or a column name.table_or_view
is char, nchar, varchar, or nvarchar.
Returns
- decimal
numeric(@@MAXPRECISION, 0))
Exceptions
Iif<T>(bool?, T, T)
Returns one of two values, depending on whether the Boolean expression evaluates to true or false in SQL Server.
[Sql.Function("SqlServer", "IIF", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Iif<T>(bool? boolean_expression, T true_value, T false_value)
Parameters
boolean_expression
bool?A valid Boolean expression.
true_value
TValue to return if
boolean_expression
evaluates to true.false_value
TValue to return if
boolean_expression
evaluates to false.
Returns
- T
Returns the data type with the highest precedence from the types in
true_value
andfalse_value
.
Type Parameters
T
Exceptions
IndexColumn(string, int, int)
Returns the indexed column name. Returns NULL for XML indexes.
[Sql.Function("SqlServer", "INDEX_COL", ServerSideOnly = true)]
public static string? IndexColumn(string table_or_view, int index_id, int key_id)
Parameters
table_or_view
stringIs the name of the table or indexed view.
table_or_view_name
must be delimited by single quotation marks and can be fully qualified by database name and schema name.index_id
intIs the ID of the index.
index_ID
is int.key_id
intIs the index key column position.
key_ID
is int.
Returns
- string
nvarchar(128)
Exceptions
IndexKeyProperty(int?, int?, int?, IndexKeyPropertyName)
INDEXKEY_PROPERTY (Transact-SQL)
Returns information about the index key. Returns NULL for XML indexes.
[Sql.Extension("SqlServer", "INDEXKEY_PROPERTY", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.IndexKeyPropertyName>))]
public static int? IndexKeyProperty(int? object_ID, int? index_ID, int? key_ID, SqlFn.IndexKeyPropertyName property)
Parameters
object_ID
int?Is the object identification number of the table or indexed view.
object_ID
is int.index_ID
int?Is the index identification number.
index_ID
is int.key_ID
int?Is the index key column position.
key_ID
is int.property
SqlFn.IndexKeyPropertyNameIs the name of the property for which information will be returned.
property
is a character string and can be one of the following values.
Returns
- int?
int
Exceptions
IndexProperty(int?, string?, IndexPropertyName)
Returns information about the index key. Returns NULL for XML indexes.
[Sql.Extension("SqlServer", "INDEXPROPERTY", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.IndexPropertyName>))]
public static int? IndexProperty(int? object_ID, string? index_or_statistics_name, SqlFn.IndexPropertyName property)
Parameters
object_ID
int?Is an expression that contains the object identification number of the table or indexed view for which to provide index property information.
object_ID
is int.index_or_statistics_name
stringIs an expression that contains the name of the index or statistics for which to return property information.
index_or_statistics_name
is nvarchar(128).property
SqlFn.IndexPropertyNameIs an expression that contains the name of the database property to return.
property
is varchar(128), and can be one of these values.
Returns
- int?
int
Exceptions
IsDate(string)
Returns 1 if the expression is a valid datetime value; otherwise, 0. ISDATE returns 0 if the expression is a datetime2 value.
[Sql.Function("SqlServer", "ISDATE", ServerSideOnly = true)]
public static int IsDate(string expression)
Parameters
expression
string
Returns
- int
int
Exceptions
IsJson(string?)
Tests whether a string contains valid JSON.
[Sql.Function("SqlServer", "ISJSON", ServerSideOnly = true)]
public static bool? IsJson(string? expression)
Parameters
expression
stringThe string to test.
Returns
- bool?
Returns 1 if the string contains valid JSON; otherwise, returns 0. Returns null if expression is null.
Exceptions
IsNull<T>(T, T)
Replaces NULL with the specified replacement value.
[Sql.Function("SqlServer", "ISNULL", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T IsNull<T>(T check_expression, T replacement_value)
Parameters
check_expression
TIs the expression to be checked for NULL.
check_expression
can be of any type.replacement_value
TIs the expression to be returned if
check_expression
is NULL.replacement_value
must be of a type that is implicitly convertible to the type ofcheck_expression
.
Returns
- T
Returns the same type as
check_expression
. If a literal NULL is provided ascheck_expression
, returns the datatype of thereplacement_value
. If a literal NULL is provided ascheck_expression
and noreplacement_value
is provided, returns an int.
Type Parameters
T
Exceptions
IsNumeric<T>(T)
Determines whether an expression is a valid numeric type.
[Sql.Function("SqlServer", "ISNUMERIC", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static int IsNumeric<T>(T expression)
Parameters
expression
TIs the expression to be evaluated.
Returns
- int
int
Type Parameters
T
Exceptions
JsonModify(string?, string, string)
Updates the value of a property in a JSON string and returns the updated JSON string.
[Sql.Function("SqlServer", "JSON_MODIFY", ServerSideOnly = true)]
public static string? JsonModify(string? expression, string path, string newValue)
Parameters
expression
stringAn expression. Typically the name of a variable or a column that contains JSON text.
path
stringA JSON path expression that specifies the property to update.
newValue
stringThe new value for the property specified by path. The new value must be a [n]varchar or text.
Returns
- string
Returns the updated value of expression as properly formatted JSON text.
Exceptions
JsonQuery(string?, string)
Extracts an object or an array from a JSON string.
[Sql.Function("SqlServer", "JSON_QUERY", ServerSideOnly = true)]
public static string? JsonQuery(string? expression, string path)
Parameters
expression
stringAn expression. Typically the name of a variable or a column that contains JSON text.
path
stringA JSON path that specifies the property to extract.
Returns
- string
Returns a JSON fragment of type nvarchar(max). The collation of the returned value is the same as the collation of the input expression.
Exceptions
JsonValue(string?, string)
Extracts a scalar value from a JSON string.
[Sql.Function("SqlServer", "JSON_VALUE", ServerSideOnly = true)]
public static string? JsonValue(string? expression, string path)
Parameters
expression
stringAn expression. Typically the name of a variable or a column that contains JSON text.
path
stringA JSON path that specifies the property to extract.
Returns
- string
Returns a single text value of type nvarchar(4000). The collation of the returned value is the same as the collation of the input expression.
Exceptions
Left(string?, int?)
Returns the left part of a character string with the specified number of characters.
[Sql.Function("SqlServer", "LEFT", ServerSideOnly = true)]
public static string? Left(string? character_expression, int? integer_expression)
Parameters
character_expression
stringIs an expression of character or binary data.
character_expression
can be a constant, variable, or column.character_expression
can be of any data type, except text or ntext, that can be implicitly converted to varchar or nvarchar. Otherwise, use the CAST function to explicitly convertcharacter_expression
.integer_expression
int?Is a positive integer that specifies how many characters of the character_expression will be returned. If
integer_expression
is negative, an error is returned. Ifinteger_expression
is type bigint and contains a large value,character_expression
must be of a large data type such as varchar(max). Theinteger_expression
parameter counts a UTF-16 surrogate character as one character.
Returns
- string
Returns varchar when
character_expression
is a non-Unicode character data type. Returns nvarchar whencharacter_expression
is a Unicode character data type.
Exceptions
LeftTrim(string?)
Returns a character expression after it removes leading blanks.
[Sql.Function("SqlServer", "LTRIM", ServerSideOnly = true)]
public static string? LeftTrim(string? character_expression)
Parameters
character_expression
stringIs the string expression of character or binary data.
character_expression
can be a constant, variable, or column.character_expression
must be of a data type that is implicitly convertible to varchar.
Returns
- string
varchar or nvarchar
Exceptions
Len(string?)
Returns the number of characters of the specified string expression, excluding trailing spaces.
[Sql.Function("SqlServer", "LEN", ServerSideOnly = true)]
public static int? Len(string? character_expression)
Parameters
character_expression
stringIs the string expression to be evaluated.
character_expression
can be a constant, variable, or column of either character or binary data.
Returns
- int?
bigint if expression is of the varchar(max), nvarchar(max) or varbinary(max) data types; otherwise, int.
Exceptions
LenBig(string?)
Returns the number of characters of the specified string expression, excluding trailing spaces.
[Sql.Function("SqlServer", "LEN", ServerSideOnly = true)]
public static long? LenBig(string? character_expression)
Parameters
character_expression
stringIs the string expression to be evaluated.
character_expression
can be a constant, variable, or column of either character or binary data.
Returns
- long?
bigint if expression is of the varchar(max), nvarchar(max) or varbinary(max) data types; otherwise, int.
Exceptions
Log10<T>(T)
Returns the base-10 logarithm of the specified float expression.
[Sql.Function("SqlServer", "LOG", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Log10<T>(T float_expression)
Parameters
float_expression
TIs an expression of type float or of a type that can be implicitly converted to float.
Returns
- T
float
Type Parameters
T
Exceptions
Log<T>(T)
Returns the natural logarithm of the specified float expression in SQL Server.
[Sql.Function("SqlServer", "LOG", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Log<T>(T float_expression)
Parameters
float_expression
TIs an expression of type float or of a type that can be implicitly converted to float.
Returns
- T
float
Type Parameters
T
Exceptions
Log<T>(T, int)
Returns the natural logarithm of the specified float expression in SQL Server.
[Sql.Function("SqlServer", "LOG", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Log<T>(T float_expression, int @base)
Parameters
float_expression
TIs an expression of type float or of a type that can be implicitly converted to float.
base
intOptional integer argument that sets the base for the logarithm.
Returns
- T
float
Type Parameters
T
Exceptions
Lower(string?)
Returns a character expression after converting uppercase character data to lowercase.
[Sql.Function("SqlServer", "LOWER", ServerSideOnly = true)]
public static string? Lower(string? character_expression)
Parameters
character_expression
stringIs the string expression of character or binary data.
character_expression
can be a constant, variable, or column.character_expression
must be of a data type that is implicitly convertible to varchar.
Returns
- string
varchar or nvarchar
Exceptions
MinActiveRowVersion()
MIN_ACTIVE_ROWVERSION (Transact-SQL)
Returns the workstation identification number. The workstation identification number is the process ID (PID) of the application on the client computer that is connecting to SQL Server.
[Sql.Function("SqlServer", "MIN_ACTIVE_ROWVERSION", ServerSideOnly = true)]
public static byte[] MinActiveRowVersion()
Returns
- byte[]
Returns a binary(8) value.
Exceptions
Month(DateTimeOffset?)
This function returns an integer that represents the day (day of the month) of the specified date
.
[Sql.Function("SqlServer", "MONTH", ServerSideOnly = true)]
public static int? Month(DateTimeOffset? date)
Parameters
date
DateTimeOffset?
Returns
- int?
int
Exceptions
Month(DateTime?)
This function returns an integer that represents the day (day of the month) of the specified date
.
[Sql.Function("SqlServer", "MONTH", ServerSideOnly = true)]
public static int? Month(DateTime? date)
Parameters
date
DateTime?
Returns
- int?
int
Exceptions
Month(string?)
Returns an integer that represents the month of the specified date.
[Sql.Function("SqlServer", "MONTH", ServerSideOnly = true)]
public static int? Month(string? date)
Parameters
date
string
Returns
- int?
int
Exceptions
NChar(int?)
Returns the Unicode character with the specified integer code, as defined by the Unicode standard.
[Sql.Function("SqlServer", "NCHAR", ServerSideOnly = true)]
public static char? NChar(int? integer_expression)
Parameters
integer_expression
int?When the collation of the database does not contain the Supplementary Character (SC) flag, this is a positive integer from 0 through 65535 (0 through 0xFFFF). If a value outside this range is specified, NULL is returned.
Returns
- char?
nchar(1) when the default database collation does not support supplementary characters. nvarchar(2) when the default database collation supports supplementary characters.
Exceptions
NewID()
Creates a unique value of type uniqueidentifier.
[Sql.Function("SqlServer", "NEWID", ServerSideOnly = true)]
public static Guid NewID()
Returns
- Guid
uniqueidentifier
Exceptions
NextValueFor(string)
Generates a sequence number from the specified sequence object.
[Sql.Extension("SqlServer", "NEXT VALUE FOR {sequence_name}", ServerSideOnly = true, BuilderType = typeof(SqlFn.NextValueForBuilder))]
public static object? NextValueFor(string sequence_name)
Parameters
sequence_name
stringThe name of the sequence object that generates the number.
Returns
- object
Returns a number using the type of the sequence.
Exceptions
NextValueForOver(string)
Generates a sequence number from the specified sequence object.
[Sql.Extension("SqlServer", "NEXT VALUE FOR {sequence_name} OVER ({order_by_clause})", ServerSideOnly = true, BuilderType = typeof(SqlFn.NextValueForBuilder), TokenName = "function", ChainPrecedence = 1, IsWindowFunction = true)]
public static AnalyticFunctions.INeedsOrderByOnly<object?> NextValueForOver(string sequence_name)
Parameters
sequence_name
stringThe name of the sequence object that generates the number.
Returns
- AnalyticFunctions.INeedsOrderByOnly<object>
Returns a number using the type of the sequence.
Exceptions
ObjectDefinition(int?)
OBJECT_DEFINITION (Transact-SQL)
Returns the Transact-SQL source text of the definition of a specified object.
[Sql.Function("SqlServer", "OBJECT_DEFINITION", ServerSideOnly = true)]
public static string? ObjectDefinition(int? object_id)
Parameters
object_id
int?Is the ID of the object to be used.
object_id
is int, and assumed to represent an object in the current database context.
Returns
- string
nvarchar(max)
Exceptions
ObjectID(string)
Returns the database object identification number of a schema-scoped object.
[Sql.Function("SqlServer", "OBJECT_ID", ServerSideOnly = true)]
public static int? ObjectID(string object_name)
Parameters
object_name
stringIs the object to be used.
object_name
is either varchar or nvarchar. Ifobject_name
is varchar, it is implicitly converted to nvarchar. Specifying the database and schema names is optional.
Returns
- int?
int
Exceptions
ObjectID(string, string)
Returns the database object identification number of a schema-scoped object.
[Sql.Function("SqlServer", "OBJECT_ID", ServerSideOnly = true)]
public static int? ObjectID(string object_name, string object_type)
Parameters
object_name
stringIs the object to be used.
object_name
is either varchar or nvarchar. Ifobject_name
is varchar, it is implicitly converted to nvarchar. Specifying the database and schema names is optional.object_type
stringIs the schema-scoped object type.
object_type
is either varchar or nvarchar. Ifobject_type
is varchar, it is implicitly converted to nvarchar. For a list of object types, see the type column in sys.objects (Transact-SQL).
Returns
- int?
int
Exceptions
ObjectName(int?)
Returns the database object name for schema-scoped objects. For a list of schema-scoped objects, see sys.objects (Transact-SQL).
[Sql.Function("SqlServer", "OBJECT_NAME", ServerSideOnly = true)]
public static string? ObjectName(int? object_id)
Parameters
object_id
int?Is the ID of the object to be used.
object_id
is int and is assumed to be a schema-scoped object in the specified database, or in the current database context.
Returns
- string
sysname
Exceptions
ObjectName(int?, int?)
Returns the database object name for schema-scoped objects. For a list of schema-scoped objects, see sys.objects (Transact-SQL).
[Sql.Function("SqlServer", "OBJECT_NAME", ServerSideOnly = true)]
public static string? ObjectName(int? object_id, int? database_id)
Parameters
object_id
int?Is the ID of the object to be used.
object_id
is int and is assumed to be a schema-scoped object in the specified database, or in the current database context.database_id
int?Is the ID of the database where the object is to be looked up.
database_id
is int.
Returns
- string
sysname
Exceptions
ObjectProperty(int?, ObjectPropertyName)
Returns information about schema-scoped objects in the current database. For a list of schema-scoped objects, see sys.objects (Transact-SQL). This function cannot be used for objects that are not schema-scoped, such as data definition language (DDL) triggers and event notifications.
[Sql.Extension("SqlServer", "OBJECTPROPERTY", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.ObjectPropertyName>))]
public static int? ObjectProperty(int? id, SqlFn.ObjectPropertyName property)
Parameters
id
int?Is an expression that represents the ID of the object in the current database.
id
is int and is assumed to be a schema-scoped object in the current database context.property
SqlFn.ObjectPropertyNameIs an expression that represents the information to be returned for the object specified by
id
.property
can be one of the following values.
Returns
- int?
int
Exceptions
ObjectPropertyEx(int?, ObjectPropertyExName)
OBJECTPROPERTYEX (Transact-SQL)
Returns information about schema-scoped objects in the current database. For a list of these objects, see sys.objects (Transact-SQL). OBJECTPROPERTYEX cannot be used for objects that are not schema-scoped, such as data definition language (DDL) triggers and event notifications.
[Sql.Extension("SqlServer", "OBJECTPROPERTYEX", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.ObjectPropertyExName>))]
public static object? ObjectPropertyEx(int? id, SqlFn.ObjectPropertyExName property)
Parameters
id
int?Is an expression that represents the ID of the object in the current database.
id
is int and is assumed to be a schema-scoped object in the current database context.property
SqlFn.ObjectPropertyExNameIs an expression that contains the information to be returned for the object specified by
id
. The return type is sql_variant. The following table shows the base data type for each property value.
Returns
- object
sql_variant
Exceptions
ObjectSchemaName(int?)
OBJECT_SCHEMA_NAME (Transact-SQL)
Returns the database schema name for schema-scoped objects. For a list of schema-scoped objects, see sys.objects (Transact-SQL).
[Sql.Function("SqlServer", "OBJECT_SCHEMA_NAME", ServerSideOnly = true)]
public static string? ObjectSchemaName(int? object_id)
Parameters
object_id
int?Is the ID of the object to be used.
object_id
is int and is assumed to be a schema-scoped object in the specified database, or in the current database context.
Returns
- string
sysname
Exceptions
ObjectSchemaName(int?, int?)
OBJECT_SCHEMA_NAME (Transact-SQL)
Returns the database schema name for schema-scoped objects. For a list of schema-scoped objects, see sys.objects (Transact-SQL).
[Sql.Function("SqlServer", "OBJECT_SCHEMA_NAME", ServerSideOnly = true)]
public static string? ObjectSchemaName(int? object_id, int? database_id)
Parameters
object_id
int?Is the ID of the object to be used.
object_id
is int and is assumed to be a schema-scoped object in the specified database, or in the current database context.database_id
int?Is the ID of the database where the object is to be looked up.
database_id
is int.
Returns
- string
sysname
Exceptions
OpenJson(string?)
A table-valued function that parses JSON text and returns objects and properties from the JSON input as rows and columns.
[Sql.TableExpression("OPENJSON({2}) {1}")]
public static IQueryable<SqlFn.JsonData> OpenJson(string? json)
Parameters
json
stringAn expression. Typically the name of a variable or a column that contains JSON text.
Returns
- IQueryable<SqlFn.JsonData>
Returns a rowset view over the elements of a JSON object or array.
Remarks
Only available on SQL Server 2016 or later, and compatibility mode for the database must be set to 130 or higher
Exceptions
OpenJson(string?, string)
A table-valued function that parses JSON text and returns objects and properties from the JSON input as rows and columns.
[Sql.TableExpression("OPENJSON({2}, {3}) {1}")]
public static IQueryable<SqlFn.JsonData> OpenJson(string? json, string path)
Parameters
json
stringAn expression. Typically the name of a variable or a column that contains JSON text.
path
stringA JSON path expression that specifies the property to query.
Returns
- IQueryable<SqlFn.JsonData>
Returns a rowset view over the elements of a JSON object or array.
Remarks
Only available on SQL Server 2016 or later, and compatibility mode for the database must be set to 130 or higher
Exceptions
OriginalDbName()
ORIGINAL_DB_NAME (Transact-SQL)
Returns the database name specified by the user in the database connection string.
This database is specified by using the sqlcmd-d option (USE database
).
It can also be specified with the Open Database Connectivity (ODBC) data source expression (initial catalog = databasename
).
This database is different from the default user database.
[Sql.Function("SqlServer", "ORIGINAL_DB_NAME", ServerSideOnly = true)]
public static string? OriginalDbName()
Returns
Exceptions
PI()
Returns the constant value of PI.
[Sql.Function("SqlServer", "PI", ServerSideOnly = true)]
public static double PI()
Returns
- double
float
Exceptions
ParseName(string?, int)
Returns the database schema name for schema-scoped objects. For a list of schema-scoped objects, see sys.objects (Transact-SQL).
[Sql.Function("SqlServer", "PARSENAME", ServerSideOnly = true)]
public static string? ParseName(string? object_name, int object_piece)
Parameters
object_name
stringIs the parameter that holds the name of the object for which to retrieve the specified object part. This parameter is an optionally-qualified object name. If all parts of the object name are qualified, this name can have four parts: the server name, the database name, the schema name, and the object name. Each part of the 'object_name' string is type sysname which is equivalent to nvarchar(128) or 256 bytes. If any part of the string exceeds 256 bytes, PARSENAME will return NULL for that part as it is not a valid sysname.
object_piece
intIs the object part to return. object_piece is of type int, and can have these values:
- 1 = Object name
- 2 = Schema name
- 3 = Database name
- 4 = Server name
Returns
- string
sysname
Exceptions
Parse<T>(string)
Returns the result of an expression, translated to the requested data type in SQL Server.
[Sql.Expression("SqlServer", "PARSE({0} as {1})", ServerSideOnly = true)]
public static T Parse<T>(string string_value)
Parameters
string_value
stringnvarchar(4000) value representing the formatted value to parse into the specified data type.
Returns
- T
Returns the result of the expression, translated to the requested data type.
Type Parameters
T
Exceptions
Parse<T>(string, SqlType<T>)
Returns the result of an expression, translated to the requested data type in SQL Server.
[Sql.Extension("SqlServer", "PARSE({string_value} as {data_type})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T Parse<T>(string string_value, SqlType<T> data_type)
Parameters
string_value
stringnvarchar(4000) value representing the formatted value to parse into the specified data type.
data_type
SqlType<T>Literal value representing the data type requested for the result.
Returns
- T
Returns the result of the expression, translated to the requested data type.
Type Parameters
T
Exceptions
Parse<T>(string, SqlType<T>, string)
Returns the result of an expression, translated to the requested data type in SQL Server.
[Sql.Extension("SqlServer", "PARSE({string_value} as {data_type} USING {culture})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T Parse<T>(string string_value, SqlType<T> data_type, string culture)
Parameters
string_value
stringnvarchar(4000) value representing the formatted value to parse into the specified data type.
data_type
SqlType<T>Literal value representing the data type requested for the result.
culture
stringOptional string that identifies the culture in which string_value is formatted.
Returns
- T
Returns the result of the expression, translated to the requested data type.
Type Parameters
T
Exceptions
Parse<T>(string, Func<SqlType<T>>)
Returns the result of an expression, translated to the requested data type in SQL Server.
[Sql.Extension("SqlServer", "PARSE({string_value} as {data_type})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T Parse<T>(string string_value, Func<SqlType<T>> data_type)
Parameters
string_value
stringnvarchar(4000) value representing the formatted value to parse into the specified data type.
data_type
Func<SqlType<T>>Literal value representing the data type requested for the result.
Returns
- T
Returns the result of the expression, translated to the requested data type.
Type Parameters
T
Exceptions
Parse<T>(string, Func<SqlType<T>>, string)
Returns the result of an expression, translated to the requested data type in SQL Server.
[Sql.Extension("SqlServer", "PARSE({string_value} as {data_type} USING {culture})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T Parse<T>(string string_value, Func<SqlType<T>> data_type, string culture)
Parameters
string_value
stringnvarchar(4000) value representing the formatted value to parse into the specified data type.
data_type
Func<SqlType<T>>Literal value representing the data type requested for the result.
culture
stringOptional string that identifies the culture in which string_value is formatted.
Returns
- T
Returns the result of the expression, translated to the requested data type.
Type Parameters
T
Exceptions
Parse<T>(string, string)
Returns the result of an expression, translated to the requested data type in SQL Server.
[Sql.Expression("SqlServer", "PARSE({0} as {2} USING {1})", ServerSideOnly = true)]
public static T Parse<T>(string string_value, string culture)
Parameters
string_value
stringnvarchar(4000) value representing the formatted value to parse into the specified data type.
culture
stringOptional string that identifies the culture in which string_value is formatted.
Returns
- T
Returns the result of the expression, translated to the requested data type.
Type Parameters
T
Exceptions
PatIndex(string?, string?)
Returns the starting position of the first occurrence of a pattern in a specified expression, or zeros if the pattern is not found, on all valid text and character data types.
[Sql.Function("SqlServer", "PATINDEX", ServerSideOnly = true)]
public static int? PatIndex(string? pattern, string? expression)
Parameters
pattern
stringIs a character expression that contains the sequence to be found. Wildcard characters can be used; however, the % character must come before and follow pattern (except when you search for first or last characters).
pattern
is an expression of the character string data type category. pattern is limited to 8000 characters.expression
stringIs an expression, typically a column that is searched for the specified pattern.
expression
is of the character string data type category.
Returns
- int?
bigint if
expression
is of the varchar(max) or nvarchar(max) data types; otherwise int.
Exceptions
PatIndexBig(string?, string?)
Returns the starting position of the first occurrence of a pattern in a specified expression, or zeros if the pattern is not found, on all valid text and character data types.
[Sql.Function("SqlServer", "PATINDEX", ServerSideOnly = true)]
public static long? PatIndexBig(string? pattern, string? expression)
Parameters
pattern
stringIs a character expression that contains the sequence to be found. Wildcard characters can be used; however, the % character must come before and follow pattern (except when you search for first or last characters).
pattern
is an expression of the character string data type category. pattern is limited to 8000 characters.expression
stringIs an expression, typically a column that is searched for the specified pattern.
expression
is of the character string data type category.
Returns
- long?
bigint if
expression
is of the varchar(max) or nvarchar(max) data types; otherwise int.
Exceptions
Power<T>(T, T)
Returns the base-10 logarithm of the specified float expression.
[Sql.Function("SqlServer", "POWER", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Power<T>(T float_expression, T y)
Parameters
float_expression
TIs an expression of type float or of a type that can be implicitly converted to float.
y
TIs the power to which to raise
float_expression
. y can be an expression of the exact numeric or approximate numeric data type category, except for the bit data type.
Returns
- T
float
Type Parameters
T
Exceptions
PublishingServerName()
PUBLISHINGSERVERNAME (Transact-SQL)
Returns the name of the originating Publisher for a published database participating in a database mirroring session. This function is executed at a Publisher instance of SQL Server on the publication database. Use it to determine the original Publisher of the published database.
[Sql.Function("SqlServer", "PUBLISHINGSERVERNAME", ServerSideOnly = true)]
public static string? PublishingServerName()
Returns
- string
nvarchar
Exceptions
QuoteName(string?)
Returns a Unicode string with the delimiters added to make the input string a valid SQL Server delimited identifier.
[Sql.Function("SqlServer", "QUOTENAME", ServerSideOnly = true)]
public static string? QuoteName(string? character_string)
Parameters
character_string
stringIs a string of Unicode character data.
character_string
is sysname and is limited to 128 characters. Inputs greater than 128 characters return NULL.
Returns
- string
nvarchar(258)
Exceptions
QuoteName(string?, string?)
Returns a Unicode string with the delimiters added to make the input string a valid SQL Server delimited identifier.
[Sql.Function("SqlServer", "QUOTENAME", ServerSideOnly = true)]
public static string? QuoteName(string? character_string, string? quote_character)
Parameters
character_string
stringIs a string of Unicode character data.
character_string
is sysname and is limited to 128 characters. Inputs greater than 128 characters return NULL.quote_character
stringIs a one-character string to use as the delimiter. Can be a single quotation mark ( ' ), a left or right bracket ( [] ), a double quotation mark ( " ), a left or right parenthesis ( () ), a greater than or less than sign ( >< ), a left or right brace ( {} ) or a backtick ( ` ). NULL returns if an unacceptable character is supplied. If
quote_character
is not specified, brackets are used.
Returns
- string
nvarchar(258)
Exceptions
Radians<T>(T)
Returns radians when a numeric expression, in degrees, is entered.
[Sql.Function("SqlServer", "RADIANS", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Radians<T>(T numeric_expression)
Parameters
numeric_expression
TAn expression of the exact numeric or approximate numeric data type category, except for the bit data type.
Returns
- T
Return values have the same type as
numeric_expression
.
Type Parameters
T
Exceptions
Random()
Returns a pseudo-random float value from 0 through 1, exclusive.
[Sql.Function("SqlServer", "RAND", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static double Random()
Returns
- double
float
Exceptions
Random(int)
Returns a pseudo-random float value from 0 through 1, exclusive.
[Sql.Function("SqlServer", "RAND", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static double Random(int seed)
Parameters
seed
int
Returns
- double
float
Exceptions
Replace(string?, string?, string?)
Replaces all occurrences of a specified string value with another string value.
[Sql.Function("SqlServer", "REPLACE", ServerSideOnly = true)]
public static string? Replace(string? string_expression, string? string_pattern, string? string_replacement)
Parameters
string_expression
stringIs the string expression to be searched.
string_expression
can be of a character or binary data type.string_pattern
stringIs the substring to be found.
string_pattern
can be of a character or binary data type.string_pattern
must not exceed the maximum number of bytes that fits on a page. Ifstring_pattern
is an empty string (''),string_expression
is returned unchanged.string_replacement
stringIs the replacement string.
string_replacement
can be of a character or binary data type.
Returns
- string
Returns nvarchar if one of the input arguments is of the nvarchar data type; otherwise, REPLACE returns varchar. Returns NULL if any one of the arguments is NULL.
Exceptions
Replicate(byte[]?, int?)
Repeats a string value a specified number of times.
[Sql.Function("SqlServer", "REPLICATE", ServerSideOnly = true)]
public static string? Replicate(byte[]? string_expression, int? integer_expression)
Parameters
string_expression
byte[]Is an expression of a character string or binary data type.
integer_expression
int?Is an expression of any integer type, including bigint. If
integer_expression
is negative, NULL is returned.
Returns
- string
Returns the same type as
string_expression
.
Exceptions
Replicate(string?, int?)
Repeats a string value a specified number of times.
[Sql.Function("SqlServer", "REPLICATE", ServerSideOnly = true)]
public static string? Replicate(string? string_expression, int? integer_expression)
Parameters
string_expression
stringIs an expression of a character string or binary data type.
integer_expression
int?Is an expression of any integer type, including bigint. If
integer_expression
is negative, NULL is returned.
Returns
- string
Returns the same type as
string_expression
.
Exceptions
Reverse(string?)
Returns the reverse order of a string value.
[Sql.Function("SqlServer", "REVERSE", ServerSideOnly = true)]
public static string? Reverse(string? string_expression)
Parameters
string_expression
stringstring_expression
is an expression of a string or binary data type.string_expression
can be a constant, variable, or column of either character or binary data.
Returns
- string
varchar or nvarchar
Exceptions
Right(string?, int?)
Returns the right part of a character string with the specified number of characters.
[Sql.Function("SqlServer", "RIGHT", ServerSideOnly = true)]
public static string? Right(string? character_expression, int? integer_expression)
Parameters
character_expression
stringIs an expression of character or binary data.
character_expression
can be a constant, variable, or column.character_expression
can be of any data type, except text or ntext, that can be implicitly converted to varchar or nvarchar. Otherwise, use the CAST function to explicitly convertcharacter_expression
.integer_expression
int?Is a positive integer that specifies how many characters of the character_expression will be returned. If
integer_expression
is negative, an error is returned. Ifinteger_expression
is type bigint and contains a large value,character_expression
must be of a large data type such as varchar(max). Theinteger_expression
parameter counts a UTF-16 surrogate character as one character.
Returns
- string
Returns varchar when
character_expression
is a non-Unicode character data type. Returns nvarchar whencharacter_expression
is a Unicode character data type.
Exceptions
RightTrim(string?)
Returns a character string after truncating all trailing spaces.
[Sql.Function("SqlServer", "RTRIM", ServerSideOnly = true)]
public static string? RightTrim(string? character_expression)
Parameters
character_expression
stringIs an expression of character data. character_expression can be a constant, variable, or column of either character or binary data.
Returns
- string
varchar or nvarchar
Exceptions
Round<T>(T, int)
Returns a numeric value, rounded to the specified length or precision.
[Sql.Function("SqlServer", "ROUND", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Round<T>(T numeric_expression, int length)
Parameters
numeric_expression
TAn expression of the exact numeric or approximate numeric data type category, except for the bit data type.
length
intIs the precision to which
numeric_expression
is to be rounded.length
must be an expression of type tinyint, smallint, or int. Whenlength
is a positive number,numeric_expression
is rounded to the number of decimal positions specified bylength
. Whenlength
is a negative number,numeric_expression
is rounded on the left side of the decimal point, as specified bylength
.
Returns
- T
Return values have the same type as
numeric_expression
.
Type Parameters
T
Exceptions
Round<T>(T, int, int)
Returns a numeric value, rounded to the specified length or precision.
[Sql.Function("SqlServer", "ROUND", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Round<T>(T numeric_expression, int length, int function)
Parameters
numeric_expression
TAn expression of the exact numeric or approximate numeric data type category, except for the bit data type.
length
intIs the precision to which
numeric_expression
is to be rounded.length
must be an expression of type tinyint, smallint, or int. Whenlength
is a positive number,numeric_expression
is rounded to the number of decimal positions specified bylength
. Whenlength
is a negative number,numeric_expression
is rounded on the left side of the decimal point, as specified bylength
.function
intIs the type of operation to perform.
function
must be tinyint, smallint, or int. When function is omitted or has a value of 0 (default),numeric_expression
is rounded. When a value other than 0 is specified,numeric_expression
is truncated
Returns
- T
Return values have the same type as
numeric_expression
.
Type Parameters
T
Exceptions
RowCountBig()
Returns the number of rows affected by the last statement executed. This function operates like @@ROWCOUNT, except the return type of ROWCOUNT_BIG is bigint.
[Sql.Function("SqlServer", "ROWCOUNT_BIG", ServerSideOnly = true)]
public static long RowCountBig()
Returns
- long
bigint
Exceptions
SchemaID()
Returns the schema ID associated with a schema name.
[Sql.Function("SqlServer", "SCHEMA_ID", ServerSideOnly = true)]
public static int? SchemaID()
Returns
- int?
int
Exceptions
SchemaID(string)
Returns the schema ID associated with a schema name.
[Sql.Function("SqlServer", "SCHEMA_ID", ServerSideOnly = true)]
public static int? SchemaID(string schema_name)
Parameters
schema_name
stringIs the name of the schema.
schema_name
is a sysname. Ifschema_name
is not specified, SCHEMA_ID will return the ID of the default schema of the caller.
Returns
- int?
int
Exceptions
SchemaName()
Returns the schema name associated with a schema ID.
[Sql.Function("SqlServer", "SCHEMA_NAME", ServerSideOnly = true)]
public static string? SchemaName()
Returns
- string
sysname
Exceptions
SchemaName(int?)
Returns the schema name associated with a schema ID.
[Sql.Function("SqlServer", "SCHEMA_NAME", ServerSideOnly = true)]
public static string? SchemaName(int? schema_id)
Parameters
schema_id
int?The ID of the schema.
schema_id
is an int. Ifschema_id
is not defined, SCHEMA_NAME will return the name of the default schema of the caller.
Returns
- string
sysname
Exceptions
ScopeIdentity()
Returns the last identity value inserted into an identity column in the same scope. A scope is a module: a stored procedure, trigger, function, or batch. Therefore, if two statements are in the same stored procedure, function, or batch, they are in the same scope.
[Sql.Function("SqlServer", "SCOPE_IDENTITY", ServerSideOnly = true)]
public static decimal ScopeIdentity()
Returns
- decimal
numeric(38,0)
Exceptions
ServerProperty(ServerPropertyName)
Returns property information about the server instance.
[Sql.Extension("SqlServer", "SERVERPROPERTY", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.ServerPropertyName>))]
public static object? ServerProperty(SqlFn.ServerPropertyName property)
Parameters
property
SqlFn.ServerPropertyNameIs an expression that contains the property information to be returned for the server.
Returns
- object
sql_variant
Exceptions
Sign<T>(T)
Returns the positive (+1), zero (0), or negative (-1) sign of the specified expression.
[Sql.Function("SqlServer", "SIGN", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Sign<T>(T numeric_expression)
Parameters
numeric_expression
TAn expression of the exact numeric or approximate numeric data type category, except for the bit data type.
Returns
- T
Return values have the same type as
numeric_expression
.
Type Parameters
T
Exceptions
Sin<T>(T, T)
Returns the trigonometric sine of the specified angle, in radians, and in an approximate numeric, float, expression.
[Sql.Function("SqlServer", "SIN", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Sin<T>(T float_expression, T y)
Parameters
float_expression
TIs an expression of type float or of a type that can be implicitly converted to float, in radians.
y
T
Returns
- T
float
Type Parameters
T
Exceptions
SmallDateTimeFromParts(int?, int?, int?, int?, int?)
SMALLDATETIMEFROMPARTS (Transact-SQL)
Returns a smalldatetime value for the specified date and time.
[Sql.Function("SqlServer", "SMALLDATETIMEFROMPARTS", ServerSideOnly = true)]
public static DateTime? SmallDateTimeFromParts(int? year, int? month, int? day, int? hour, int? minute)
Parameters
Returns
- DateTime?
datetime
Exceptions
SoundEx(string?)
Returns a four-character (SOUNDEX) code to evaluate the similarity of two strings.
[Sql.Function("SqlServer", "SOUNDEX", ServerSideOnly = true)]
public static string? SoundEx(string? character_expression)
Parameters
character_expression
stringIs an alphanumeric expression of character data. character_expression can be a constant, variable, or column.
Returns
- string
varchar
Exceptions
Space(int?)
Returns a string of repeated spaces.
[Sql.Function("SqlServer", "SPACE", ServerSideOnly = true)]
public static string? Space(int? integer_expression)
Parameters
integer_expression
int?Is a positive integer that indicates the number of spaces. If integer_expression is negative, a null string is returned.
Returns
- string
varchar
Exceptions
Sqrt<T>(T)
Returns the square root of the specified float value.
[Sql.Function("SqlServer", "SQRT", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Sqrt<T>(T float_expression)
Parameters
float_expression
TIs an expression of type float or of a type that can be implicitly converted to float.
Returns
- T
float
Type Parameters
T
Exceptions
Square<T>(T)
Returns the square of the specified float value.
[Sql.Function("SqlServer", "SQUARE", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Square<T>(T float_expression)
Parameters
float_expression
TIs an expression of type float or of a type that can be implicitly converted to float.
Returns
- T
float
Type Parameters
T
Exceptions
StatsDate(int?, int?)
Returns the date of the most recent update for statistics on a table or indexed view.
[Sql.Function("SqlServer", "STATS_DATE", ServerSideOnly = true)]
public static DateTime? StatsDate(int? object_id, int? stats_id)
Parameters
object_id
int?ID of the table or indexed view with the statistics.
stats_id
int?ID of the statistics object.
Returns
- DateTime?
Returns datetime on success. Returns NULL if a statistics blob was not created.
Exceptions
Str<T>(T?)
Returns character data converted from numeric data. The character data is right-justified, with a specified length and decimal precision.
[Sql.Function("SqlServer", "STR", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static string? Str<T>(T? float_expression)
Parameters
float_expression
TIs an expression of approximate numeric (float) data type with a decimal point.
Returns
- string
varchar
Type Parameters
T
Exceptions
Str<T>(T?, int)
Returns character data converted from numeric data. The character data is right-justified, with a specified length and decimal precision.
[Sql.Function("SqlServer", "STR", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static string? Str<T>(T? float_expression, int length)
Parameters
float_expression
TIs an expression of approximate numeric (float) data type with a decimal point.
length
intIs the total length. This includes decimal point, sign, digits, and spaces. The default is 10.
Returns
- string
varchar
Type Parameters
T
Exceptions
Str<T>(T?, int, int)
Returns character data converted from numeric data. The character data is right-justified, with a specified length and decimal precision.
[Sql.Function("SqlServer", "STR", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static string? Str<T>(T? float_expression, int length, int @decimal)
Parameters
float_expression
TIs an expression of approximate numeric (float) data type with a decimal point.
length
intIs the total length. This includes decimal point, sign, digits, and spaces. The default is 10.
decimal
intIs the number of places to the right of the decimal point. decimal must be less than or equal to 16. If decimal is more than 16 then the result is truncated to sixteen places to the right of the decimal point.
Returns
- string
varchar
Type Parameters
T
Exceptions
StringEscape(string?, string?)
Returns character data converted from numeric data. The character data is right-justified, with a specified length and decimal precision.
[Sql.Function("SqlServer", "STRING_ESCAPE", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static string? StringEscape(string? text, string? type)
Parameters
text
stringIs a nvarchar expression expression representing the object that should be escaped.
type
stringEscaping rules that will be applied. Currently the value supported is
'json'
.
Returns
- string
varchar
Exceptions
Stuff(string?, int?, int?, string?)
The STUFF function inserts a string into another string. It deletes a specified length of characters in the first string at the start position and then inserts the second string into the first string at the start position.
[Sql.Function("SqlServer", "STUFF", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static string? Stuff(string? character_expression, int? start, int? length, string? replaceWith_expression)
Parameters
character_expression
stringIs an expression of character data.
character_expression
can be a constant, variable, or column of either character or binary data.start
int?Is an integer value that specifies the location to start deletion and insertion. If
start
is negative or zero, a null string is returned. If start is longer than the firstcharacter_expression
, a null string is returned. start can be of type bigint.length
int?Is an integer that specifies the number of characters to delete. If
length
is negative, a null string is returned. Iflength
is longer than the firstcharacter_expression
, deletion occurs up to the last character in the lastcharacter_expression
. Iflength
is zero, insertion occurs at start location and no characters are deleted. length can be of type bigint.replaceWith_expression
stringIs an expression of character data.
character_expression
can be a constant, variable, or column of either character or binary data. This expression replaceslength
characters ofcharacter_expression
beginning at start. ProvidingNULL
as thereplaceWith_expression
, removes characters without inserting anything.
Returns
- string
Returns character data if character_expression is one of the supported character data types. Returns binary data if character_expression is one of the supported binary data types.
Exceptions
Substring(string?, int?, int?)
Returns part of a character, binary, text, or image expression in SQL Server.
[Sql.Function("SqlServer", "SUBSTRING", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static string? Substring(string? expression, int? start, int? length)
Parameters
expression
stringIs a character, binary, text, ntext, or image expression.
start
int?Is an integer or bigint expression that specifies where the returned characters start. (The numbering is 1 based, meaning that the first character in the expression is 1). If
start
is less than 1, the returned expression will begin at the first character that is specified inexpression
. In this case, the number of characters that are returned is the largest value of either the sum ofstart + length
- 1 or 0. Ifstart
is greater than the number of characters in the value expression, a zero-length expression is returned.length
int?Is a positive integer or bigint expression that specifies how many characters of the
expression
will be returned. Iflength
is negative, an error is generated and the statement is terminated. If the sum of start andlength
is greater than the number of characters inexpression
, the whole value expression beginning at start is returned.
Returns
- string
Returns character data if expression is one of the supported character data types. Returns binary data if expression is one of the supported binary data types.
Exceptions
SwitchOffset(DateTimeOffset?, string)
Returns a datetimeoffset value that is changed from the stored time zone offset to a specified new time zone offset.
[Sql.Function("SqlServer", "SWITCHOFFSET", ServerSideOnly = true)]
public static DateTimeOffset? SwitchOffset(DateTimeOffset? datetimeoffset_expression, string timezoneoffset_expression)
Parameters
datetimeoffset_expression
DateTimeOffset?timezoneoffset_expression
string
Returns
- DateTimeOffset?
int
Exceptions
SysDatetime()
Returns a datetime2(7) value that contains the date and time of the computer on which the instance of SQL Server is running.
[Sql.Function("SqlServer", "SYSDATETIME", ServerSideOnly = true)]
public static DateTime SysDatetime()
Returns
- DateTime
datetime2(7)
Exceptions
SysDatetimeOffset()
SYSDATETIMEOFFSET (Transact-SQL)
Returns a datetimeoffset(7) value that contains the date and time of the computer on which the instance of SQL Server is running. The time zone offset is included.
[Sql.Function("SqlServer", "SYSDATETIMEOFFSET", ServerSideOnly = true)]
public static DateTimeOffset SysDatetimeOffset()
Returns
- DateTimeOffset
datetimeoffset(7)
Exceptions
SysUtcDatetime()
Returns a datetime2 value that contains the date and time of the computer on which the instance of SQL Server is running. The date and time is returned as UTC time (Coordinated Universal Time). The fractional second precision specification has a range from 1 to 7 digits. The default precision is 7 digits.
[Sql.Function("SqlServer", "SYSUTCDATETIME", ServerSideOnly = true)]
public static DateTime SysUtcDatetime()
Returns
- DateTime
datetime2
Exceptions
Tan<T>(T)
Returns the tangent of the input expression.
[Sql.Function("SqlServer", "TAN", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static T Tan<T>(T float_expression)
Parameters
float_expression
TIs an expression of type float or of a type that can be implicitly converted to float.
Returns
- T
float
Type Parameters
T
Exceptions
TimeFromParts(int?, int?, int?)
This function returns a date value that maps to the specified year, month, and day values.
[Sql.Expression("SqlServer", "TIMEFROMPARTS({0}, {1}, {2}, 0, 0)", ServerSideOnly = true)]
public static TimeSpan? TimeFromParts(int? hour, int? minute, int? seconds)
Parameters
Returns
- TimeSpan?
date
Exceptions
TimeFromParts(int?, int?, int?, int?, int?)
This function returns a date value that maps to the specified year, month, and day values.
[Sql.Function("SqlServer", "TIMEFROMPARTS", ServerSideOnly = true)]
public static TimeSpan? TimeFromParts(int? hour, int? minute, int? seconds, int? fractions, int? precision)
Parameters
Returns
- TimeSpan?
date
Exceptions
ToDatetimeOffset(DateTimeOffset?, string)
TODATETIMEOFFSET (Transact-SQL)
Returns a datetimeoffset value that is translated from a datetime2 expression.
[Sql.Function("SqlServer", "TODATETIMEOFFSET", ServerSideOnly = true)]
public static DateTimeOffset? ToDatetimeOffset(DateTimeOffset? datetime_expression, string timezoneoffset_expression)
Parameters
datetime_expression
DateTimeOffset?timezoneoffset_expression
string
Returns
- DateTimeOffset?
int
Exceptions
Translate(string?, string?, string?)
Returns part of a character, binary, text, or image expression in SQL Server.
[Sql.Function("SqlServer", "TRANSLATE", ServerSideOnly = true, IgnoreGenericParameters = true)]
public static string? Translate(string? inputString, string? characters, string? translations)
Parameters
inputString
stringinputString
Is the string expression to be searched.inputString
can be any character data type (nvarchar, varchar, nchar, char).characters
stringtranslations
stringIs a string expression containing the replacement characters.
translations
must be the same data type and length as characters.
Returns
- string
Returns a character expression of the same data type as
inputString
where characters from the second argument are replaced with the matching characters from third argument.
Exceptions
Trim(string?)
Removes the space character char(32)
or other specified characters from the start and end of a string.
[Sql.Function("SqlServer", "TRIM", ServerSideOnly = true)]
public static string? Trim(string? @string)
Parameters
string
stringIs an expression of any character type (
nvarchar
,varchar
,nchar
, orchar
) where characters should be removed.
Returns
- string
Returns a character expression with a type of string argument where the space character
char(32)
or other specified characters are removed from both sides. ReturnsNULL
if input string isNULL
.
Exceptions
Trim(string, string?)
Removes the space character char(32)
or other specified characters from the start and end of a string.
[Sql.Expression("SqlServer", "TRIM({0} FROM {1})", ServerSideOnly = true)]
public static string? Trim(string characters, string? @string)
Parameters
characters
stringIs a literal, variable, or function call of any non-LOB character type (
nvarchar
,varchar
,nchar
, orchar
) containing characters that should be removed.nvarchar(max)
andvarchar(max)
types aren't allowed.string
stringIs an expression of any character type (
nvarchar
,varchar
,nchar
, orchar
) where characters should be removed.
Returns
- string
Returns a character expression with a type of string argument where the space character
char(32)
or other specified characters are removed from both sides. ReturnsNULL
if input string isNULL
.
Exceptions
TryCast<T>(object?)
These functions convert an expression of one data type to another.
[Sql.Expression("SqlServer", "TRY_CAST({0} as {1})", ServerSideOnly = true)]
public static T TryCast<T>(object? expression)
Parameters
expression
objectAny valid expression.
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
TryCast<T>(object?, SqlType<T>)
These functions convert an expression of one data type to another.
[Sql.Extension("SqlServer", "TRY_CAST({expression} as {data_type})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T TryCast<T>(object? expression, SqlType<T> data_type)
Parameters
expression
objectAny valid expression.
data_type
SqlType<T>The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
TryCast<T>(object?, Func<SqlType<T>>)
These functions convert an expression of one data type to another.
[Sql.Extension("SqlServer", "TRY_CAST({expression} as {data_type})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T TryCast<T>(object? expression, Func<SqlType<T>> data_type)
Parameters
expression
objectAny valid expression.
data_type
Func<SqlType<T>>The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
TryConvert<T>(SqlType<T>, object?)
These functions convert an expression of one data type to another.
[Sql.Extension("SqlServer", "TRY_CONVERT({data_type}, {expression})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T TryConvert<T>(SqlType<T> data_type, object? expression)
Parameters
data_type
SqlType<T>The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.
expression
objectAny valid expression.
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
TryConvert<T>(SqlType<T>, object?, int)
These functions convert an expression of one data type to another.
[Sql.Extension("SqlServer", "TRY_CONVERT({data_type}, {expression}, {style})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T TryConvert<T>(SqlType<T> data_type, object? expression, int style)
Parameters
data_type
SqlType<T>The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.
expression
objectAny valid expression.
style
int
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
TryConvert<T>(Func<SqlType<T>>, object?)
These functions convert an expression of one data type to another.
[Sql.Extension("SqlServer", "TRY_CONVERT({data_type}, {expression})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T TryConvert<T>(Func<SqlType<T>> data_type, object? expression)
Parameters
data_type
Func<SqlType<T>>The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.
expression
objectAny valid expression.
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
TryConvert<T>(Func<SqlType<T>>, object?, int)
These functions convert an expression of one data type to another.
[Sql.Extension("SqlServer", "TRY_CONVERT({data_type}, {expression}, {style})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T TryConvert<T>(Func<SqlType<T>> data_type, object? expression, int style)
Parameters
data_type
Func<SqlType<T>>The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.
expression
objectAny valid expression.
style
int
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
TryConvert<T>(object?)
These functions convert an expression of one data type to another.
[Sql.Expression("SqlServer", "TRY_CONVERT({1}, {0})", ServerSideOnly = true)]
public static T TryConvert<T>(object? expression)
Parameters
expression
objectAny valid expression.
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
TryConvert<T>(object?, int)
These functions convert an expression of one data type to another.
[Sql.Expression("SqlServer", "TRY_CONVERT({2}, {0}, {1})", ServerSideOnly = true)]
public static T TryConvert<T>(object? expression, int style)
Parameters
expression
objectAny valid expression.
style
int
Returns
- T
Returns expression, translated to data_type.
Type Parameters
T
Exceptions
TryParse<T>(string)
Returns the result of an expression, translated to the requested data type in SQL Server.
[Sql.Expression("SqlServer", "TRY_PARSE({0} as {1})", ServerSideOnly = true)]
public static T TryParse<T>(string string_value)
Parameters
string_value
stringnvarchar(4000) value representing the formatted value to parse into the specified data type.
Returns
- T
Returns the result of the expression, translated to the requested data type.
Type Parameters
T
Exceptions
TryParse<T>(string, SqlType<T>)
Returns the result of an expression, translated to the requested data type in SQL Server.
[Sql.Extension("SqlServer", "TRY_PARSE({string_value} as {data_type})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T TryParse<T>(string string_value, SqlType<T> data_type)
Parameters
string_value
stringnvarchar(4000) value representing the formatted value to parse into the specified data type.
data_type
SqlType<T>Literal value representing the data type requested for the result.
Returns
- T
Returns the result of the expression, translated to the requested data type.
Type Parameters
T
Exceptions
TryParse<T>(string, SqlType<T>, string)
Returns the result of an expression, translated to the requested data type in SQL Server.
[Sql.Extension("SqlServer", "TRY_PARSE({string_value} as {data_type} USING {culture})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T TryParse<T>(string string_value, SqlType<T> data_type, string culture)
Parameters
string_value
stringnvarchar(4000) value representing the formatted value to parse into the specified data type.
data_type
SqlType<T>Literal value representing the data type requested for the result.
culture
stringOptional string that identifies the culture in which string_value is formatted.
Returns
- T
Returns the result of the expression, translated to the requested data type.
Type Parameters
T
Exceptions
TryParse<T>(string, Func<SqlType<T>>)
Returns the result of an expression, translated to the requested data type in SQL Server.
[Sql.Extension("SqlServer", "TRY_PARSE({string_value} as {data_type})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T TryParse<T>(string string_value, Func<SqlType<T>> data_type)
Parameters
string_value
stringnvarchar(4000) value representing the formatted value to parse into the specified data type.
data_type
Func<SqlType<T>>Literal value representing the data type requested for the result.
Returns
- T
Returns the result of the expression, translated to the requested data type.
Type Parameters
T
Exceptions
TryParse<T>(string, Func<SqlType<T>>, string)
Returns the result of an expression, translated to the requested data type in SQL Server.
[Sql.Extension("SqlServer", "TRY_PARSE({string_value} as {data_type} USING {culture})", ServerSideOnly = true, BuilderType = typeof(SqlFn.DataTypeBuilder))]
public static T TryParse<T>(string string_value, Func<SqlType<T>> data_type, string culture)
Parameters
string_value
stringnvarchar(4000) value representing the formatted value to parse into the specified data type.
data_type
Func<SqlType<T>>Literal value representing the data type requested for the result.
culture
stringOptional string that identifies the culture in which string_value is formatted.
Returns
- T
Returns the result of the expression, translated to the requested data type.
Type Parameters
T
Exceptions
TryParse<T>(string, string)
Returns the result of an expression, translated to the requested data type in SQL Server.
[Sql.Expression("SqlServer", "TRY_PARSE({0} as {2} USING {1})", ServerSideOnly = true)]
public static T TryParse<T>(string string_value, string culture)
Parameters
string_value
stringnvarchar(4000) value representing the formatted value to parse into the specified data type.
culture
stringOptional string that identifies the culture in which string_value is formatted.
Returns
- T
Returns the result of the expression, translated to the requested data type.
Type Parameters
T
Exceptions
TypeID(string)
Returns the ID for a specified data type name.
[Sql.Function("SqlServer", "TYPE_ID", ServerSideOnly = true)]
public static int? TypeID(string type_name)
Parameters
type_name
stringIs the name of the data type. type_name is of type nvarchar.
type_name
can be a system or user-defined data type.
Returns
- int?
int
Exceptions
TypeName(int?)
Returns the unqualified type name of a specified type ID.
[Sql.Function("SqlServer", "TYPE_NAME", ServerSideOnly = true)]
public static string? TypeName(int? type_id)
Parameters
type_id
int?Is the ID of the type that will be used.
type_id
is an int, and it can refer to a type in any schema that the caller has permission to access.
Returns
- string
sysname
Exceptions
TypeProperty(string?, TypePropertyName)
Returns information about a data type.
[Sql.Extension("SqlServer", "TYPEPROPERTY", ServerSideOnly = true, BuilderType = typeof(SqlFn.PropertyBuilder<SqlFn.TypePropertyName>))]
public static int? TypeProperty(string? type, SqlFn.TypePropertyName property)
Parameters
type
stringIs the name of the data type.
property
SqlFn.TypePropertyNameIs the type of information to be returned for the data type.
Returns
- int?
int
Exceptions
Unicode(string)
Removes the space character char(32)
or other specified characters from the start and end of a string.
[Sql.Function("SqlServer", "UNICODE", ServerSideOnly = true)]
public static int? Unicode(string ncharacter_expression)
Parameters
ncharacter_expression
stringIs an nchar or nvarchar expression.
Returns
- int?
int
Exceptions
Upper(string?)
Returns a character expression after converting uppercase character data to lowercase.
[Sql.Function("SqlServer", "UPPER", ServerSideOnly = true)]
public static string? Upper(string? character_expression)
Parameters
character_expression
stringIs the string expression of character or binary data.
character_expression
can be a constant, variable, or column.character_expression
must be of a data type that is implicitly convertible to varchar.
Returns
- string
varchar or nvarchar
Exceptions
XactState()
Is a scalar function that reports the user transaction state of a current running request. XACT_STATE indicates whether the request has an active user transaction, and whether the transaction is capable of being committed.
[Sql.Function("SqlServer", "XACT_STATE", ServerSideOnly = true)]
public static short XactState()
Returns
- short
smallint
Exceptions
Year(DateTimeOffset?)
This function returns an integer that represents the day (day of the month) of the specified date
.
[Sql.Function("SqlServer", "YEAR", ServerSideOnly = true)]
public static int? Year(DateTimeOffset? date)
Parameters
date
DateTimeOffset?
Returns
- int?
int
Exceptions
Year(DateTime?)
This function returns an integer that represents the day (day of the month) of the specified date
.
[Sql.Function("SqlServer", "YEAR", ServerSideOnly = true)]
public static int? Year(DateTime? date)
Parameters
date
DateTime?
Returns
- int?
int
Exceptions
Year(string?)
Returns an integer that represents the year of the specified date
.
[Sql.Function("SqlServer", "YEAR", ServerSideOnly = true)]
public static int? Year(string? date)
Parameters
date
string
Returns
- int?
int