2 --Mathematical Functions3 Select CEILING(COUNT(*)/5.0) fromNews--take the smallest integer greater than the result4 Select Floor(COUNT(*)/5.0) fromNews--take the largest integer less than the result5 Select SQRT(2)--Value Open Square6 Select ROUND(3.45645,2)7 Select ABS(-5): The absolute value function, which takes the absolute value of this number, can be applied to the addition and subtraction of some of the more chaotic values in the database. 8 9 --String FunctionsTen Select LOWER('RGFRG')--uppercase letters become lowercase One Select LOWER('GGFGRT')--lowercase letters into uppercase letters A Select LTRIM()--Remove the left word spaces lattice - - Select RTRIM()--remove whitespace to the right of the string the Select Left(Title,5) fromNews--the length of string to intercept from the left of a column - Select Right(Title,5) fromNews--to intercept a string of more than one length from the right side of a column - Select SUBSTRING(Title,3,5) fromNews--To intercept a few characters from the first character in a column - Select REVERSE(Title) fromNews--Flip a column + Select CHARINDEX('China', Title) fromNews--the query target content does not appear in the specified area and where it appears - Select REPLACE(Title,'China','United States') fromNews--The replacement string. Example search keywords and clearly marked + Select STUFF(Title,3,4,'Chine') fromNews A Other Functions at Select CEILING(RAND()*Ten)--randomly generates a number between 1, which can be multiplied to increase the range of random numbers - Select LEN('Chine')--Take string length - Select GETDATE()--Get current Time - Select Year(Sbirthday) fromStudent--year of taking time - Select Month(Sbirthday) fromStudent--Date Time Month - Select Day(Sbirthday) fromStudent3--take the time of day in Select DatePart(Yy,sbirthday) fromStudent4--Yy,mm,dd, respectively, represents the month and day - Select CAST('123' as int)--Convert String
General functions of the database (mathematical functions, String functions, other functions)