Programming in MS SQL Server 2012

System Functions



Function APP_NAME
Description Returns the application name for the current session if set by the application.
Example DECLARE @CurrentApp varchar(35)

SET @CurrentApp = APP_NAME( )
IF @CurrentApp <> 'MS SQL Query Analyzer'
PRINT 'This process was not started by a SQL Query Analyzer query session.'
Result This process was not started by a SQL Query Analyzer query session.

* * * * *

Function HOST_ID
Description Returns the workstation identification number.
Example SELECT HOST_ID( )
Result 7016

* * * * *

Function HOST_NAME
Description Returns the workstation name.
Example SELECT HOST_NAME( )
Result DATA-E-EDUCATION

* * * * *

Function ISDATE
Description Determines an input expression is a valid date data.
Example SELECT ISDATE('12/31/2000')
Result 1
Example SELECT ISDATE('31/12/2000')
Result 0

* * * * *

Function ISNUMERIC
Description Determines an expression is a valid numeric data.
Example SELECT ISNUMERIC('12345')
Result 1
Example SELECT ISNUMERIC('PREM')
Result 0

* * * * *

Function ISNULL
Description Replaces NULL with the specified replacement data value.
Example SELECT ISNULL(Dept_Code,123) FROM EMP
Result 10
10
30
40
50
123

* * * * *

Function SERVERPROPERTY
Description Returns property information about the server instance.
Example SELECT SERVERPROPERTY('Edition')
Result Enterprise Evaluation Edition (64-bit)
Example SELECT SERVERPROPERTY('LicenseType')
Result DISABLED
Example SELECT SERVERPROPERTY('MachineName')
Result DATA-E-EDUCATION
Example SELECT SERVERPROPERTY('NumLicenses')
Result NULL
Example SELECT SERVERPROPERTY('ProcessID')
Result 928
Example SELECT SERVERPROPERTY('ProductVersion')
Result 11.0.3128.0
Example SELECT SERVERPROPERTY('ProductLevel')
Result SP1
Example SELECT SERVERPROPERTY('ServerName')
Result DATA-E-EDUCATION

* * * * *


Email Your Comment To AUTHOR