System Functions

The .NET Framework Data Provider for SQL Server (SqlClient) provides the following system functions:

Function Description

CHECKSUM (value, [value, [value]])

Returns the checksum value. CHECKSUM is intended for use in building hash indexes.

Arguments

value: A Boolean, Byte, Int16, Int32, Int64, Single, Decimal, Double, DateTime, String, Binary, or Guid. You can specify one, two or three values.

Return Value

The absolute value of the specified expression.

Example

SqlServer.CHECKSUM(10,100,1000.0)

CURRENT_TIMESTAMP ()

Produces the current date and time in SQL Server internal format for DateTime values with a precision of 7 in SQL Server 2008 and a precision of 3 in SQL Server 2005.

Return Value

The current system date and time as a DateTime.

Example

SqlServer.CURRENT_TIMESTAMP()

CURRENT_ USER ()

Returns the name of the current user.

Return Value

An ASCII String.

Example

SqlServer.CURRENT_USER()

DATALENGTH (expression)

Returns the number of bytes used to represent any expression.

Arguments

expression: A Boolean, Byte, Int16, Int32, Int64, Single, Decimal, Double, DateTime, Time, DateTimeOffset, String, Binary, or Guid.

Return Value

The size of properties as an Int32.

Example

SELECT VALUE SqlServer.DATALENGTH(P.Name)FROM

AdventureWorksEntities.Product AS P

HOST_NAME()

Returns the workstation name.

Return Value

A Unicode String.

Example

SqlServer.HOST_NAME()

ISDATE(expression)

Determines whether an input expression is a valid date.

Arguments

expression: A Boolean, Byte, Int16, Int32, Int64, Single, Decimal, Double, DateTime, Time, DateTimeOffset, String, Binary, or Guid.

Return Value

An Int32. One (1) if the input expression is a valid date. Zero (0) otherwise.

Example

SqlServer.ISDATE('1/1/2006')

ISNUMERIC(expression)

Determines whether an expression is a valid numeric type.

Arguments

expression: A Boolean, Byte, Int16, Int32, Int64, Single, Decimal, Double, DateTime, Time, DateTimeOffset, String, Binary, or Guid.

Return Value

An Int32. One (1) if the input expression is a valid date. Zero (0) otherwise.

Example

SqlServer.ISNUMERIC('21')

NEWID()

Creates a unique value of type Guid.

Return Value

A Guid.

Example

SqlServer.NEWID()

USER_NAME(id)

Returns a database user name from a specified identification number.

Arguments

expression: An Int32 identification number associated with a database user.

Return Value

A Unicode String.

Example

SqlServer.USER_NAME(0)

For more information about the string functions that SqlClient supports, see the documentation for the SQL Server version that you specified in the SqlClient provider manifest:

SQL Server 2000 SQL Server 2005 SQL Server 2008

System Functions Transact-SQL)

System Functions Transact-SQL)

System Functions (Transact-SQL)

See Also

Concepts

Entity SQL Language
SqlClient for Entity Framework Functions