1.

Functions in SQL

Answer»

The SQL Server has many builtin functions some of which are listed below:

  • SQL Server String Functions:

The table below lists some of the String functions in SQL with their description:

NameDescription
ASCIIReturns ASCII values for a specific character.
CHARReturns character based on the ASCII code.
CONCATConcatenates 2 strings together.
SOUNDEXReturns similarity of 2 strings in terms of a 4 character code.
DIFFERENCECompares 2 SOUNDEX values and returns the result as an integer.
SUBSTRINGExtracts a substring from a given string.
TRIMRemoves leading and trailing whitespaces from a string.
UPPERConverts a string to upper-case.
  • SQL Server Numeric Functions:

The table below lists some of the Numeric functions in SQL with their description:

NameDescription
ABSReturns the absolute value of a number.
ASINReturns arc sine value of a number.
AVGReturns average value of an expression.
COUNTCounts the number of records returned by a SELECT query.
EXPReturns e raised to the power of a number.
FLOORReturns the greatest integer <= the number.
RANDReturns a random number.
SIGNReturns the sign of a number.
SQRTReturns the square root of a number.
SUMReturns the sum of a set of values.
  • SQL Server Date Functions:

The table below lists some of the Date functions in SQL with their description:

NameDescription
CURRENT_TIMESTAMPReturns current date and time.
DATEADDAdds a date/time interval to date and returns the new date.
DATENAMEReturns a specified part of a date(as a string).
DATEPARTReturns a specified part of a date(as an integer).
DAYReturns the day of the month for a specified date.
GETDATEReturns the current date and time from the database.
  • SQL Server Advanced Functions:

The table below lists some of the Advanced functions in SQL with their description:

NameDescription
CASTTypecasts a value into specified datatype.
CONVERTConverts a value into a specified datatype.
IIFReturn a value if a condition evaluates to True, else some other value.
ISNULLReturn a specified value if the expression is NULL, else returns the expression.
ISNUMERICChecks if an expression is numeric or not.
SYSTEM_USERReturns the login name for the current user
USER_NAMEReturns the database user name based on the specified id.



Discussion

No Comment Found