Below are the many functions I use in sqlserver. What other functions do you use? Or which function is useful? Or what functions do you not need?
Left (character_expression, integer_expression)
Returns the number of characters starting from the left of the string.
Example:
Select left ('My name is viwo ', 4)
My n
Right (character_expression, integer_expression)
Returns the number of integer_expression characters specified from the right.
Example:
Select right ('My name is viwo ', 4)
Viwo
Cast (expression as data_type)
Explicitly converts a data type expression to another data type. Cast and convert provide similar functions.
Example:
Select cast (2 as varchar (10) + Cast (11 as varchar (10 ))
211
Convert (data_type [(length)], expression [, style])
Explicitly converts a data type expression to another data type. Cast and convert provide similar functions.
Example:
Select convert (varchar, getdate (), 112)
20070328
Dateadd (datepart, number, date)
Returns a new datetime value based on a specified date.
Example:
Select dateadd (month, 2, getdate ())
14:24:37. 280
Coalesce (expression [,... n])
Returns the first non-empty expression in the parameter.
Example:
Select coalesce (null, null, 0)
0
Select coalesce (2, 3, 0)
2
Charindex (expression1, expression2 [, start_location])
Returns the starting position of the specified expression in the string.
Example:
Select charindex ('AB', 'abcd ')
2
Ltrim (character_expression)
Returns a character expression after the start space is deleted.
Example:
Select ltrim ('abc ')
ABC
Rtrim (character_expression)
Returns a string after all trailing spaces are truncated.
Example:
Select rtrim ('abc ')
ABC
Round (numeric_expression, length [, function])
Returns a numeric expression rounded to the specified length or precision.
Example:
Select round (748.585, 2)
748.590
Floor (numeric_expression)
Returns the maximum integer that is less than or equal to the given numeric expression.
Example:
Select floor (748.585)
748
Ceiling (numeric_expression)
Returns the smallest integer greater than or equal to the given numeric expression.
Example:
Select ceiling (1, 748.585)
749
Replace ('string _ expression1', 'string _ expression2', 'string _ expression3 ')
Replace all the second given string expressions in the first string expression with the third expression.
Example:
Select Replace ('dalian XXXX office Dalian XXXX ', 'dalian', 'beijing ')
Beijing XXXX Office
Count
Sum
Min
Max
AVG
Needless to say, five common collection functions