SQL Server Common built-in functions and usage
Select cast (' 2012/02/03 ' as DateTime);
Select CONVERT (varchar, GETDATE (), 120);--Convert to date type
Select Case when ID =1 THEN ' A0 ' ELSE ' TT ' "from Demo1;--case '
Select Len (' SSA Edison ')--Returns 6 length
Select Left (' Seaa ', 2)--se from the top two characters
Select Right (' SEAA ', 2)--aa two characters from the right-hand side
Select LTRIM (' DS ')--remove the left space Rtrim () remove the right space
Select replace (' I hate ', ' hate ', ' love ')--return I love to You
Select STUFF (' Test do it ', 2,4, ' hh ')--parameter Description 1 primitive string 2 start position 3 End position 4 Replace string
Select GETDATE (), getUTCDate ()
Select DATEDIFF (Dd,getdate (), cast (' 2001-03-27 ' as datetime)--Returns the difference between two dates
Select DATEADD (Mm,12,getdate ()); --Make the addition of the day or month, such as shorthand Dd-day mm-month Wk-week
Select Datename (Dd,getdate ())--Returns the string format of the specified part of the date
Select ABS (-12)--Returns the absolute value of the corresponding number
Select CEILING (4.2)-5 returns the smallest integer greater than or equal to an expression
Select Floor (4.2)--4 returns the largest integer less than or equal to an expression
Select Power (2,4)--represents 2 of the 4-time side
Select sign ( -12)---1 return 1 negative for integer return-1 0 return 0
Select sqrt (25)--5 square root
Select ROUND (5.4,0.1)--rounded to specified precision
Select REVERSE (' abc ')--CBA reverse output
Select substring (' dese0w ', 2,4); --cut four bits from the second start
Select REPLICATE (' sa ', 3)--Repeat Expression