Đang chuẩn bị liên kết để tải về tài liệu:
Using Functions phần 2
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
You use the POWER() function to get the value of a number raised to a specified power. The following example returns 8: SELECT POWER(2, 3) | You use the POWER function to get the value of a number raised to a specified power. The following example returns 8 SELECT POWER 2 3 You use the ROUND function to get the value of a number rounded or truncated to a specified length. The following example returns 1.23500 which is 1.23456 rounded to three decimal places SELECT ROUND 1.23456 3 The next example passes a non-zero number as the third parameter to ROUND which indicates that the number is to be truncated rather than rounded as was done in the previous example SELECT ROUND 1.23456 3 1 This example returns 1.23400 which is 1.23456 truncated to three decimal places. You use the SQUARE function to get the square of a number. The following example returns 16.0 SELECT SQUARE 4 You use the SQRT function to get the square root of a number. The following example returns 4.0 SELECT SQRT 16 Using String Functions The string functions allow you to manipulate strings. For example you can replace specified characters in a string. Table 4.5 lists the string functions available in SQL Server. Table 4.5 STRING FUNCTIONS FUNCTION DESCRIPTION ASCII charExpression Returns the ASCII code for the leftmost character of charExpression. CHAR intExpression Returns the character that corresponds to the ASCII code specified by intExpression. CHARINDEX charExpressionl Returns the position of the characters specified by Table 4.5 STRING FUNCTIONS FUNCTION DESCRIPTION charExpression2 start charExpressionl in charExpression2 starting at the optional position specified by start. DIFFERENCE charExpressionl charExpression2 Returns the difference between the SOUNDEX values of the two character expressions. You use the SOUNDEX code to evaluate the phonetic similarity of two strings. The returned value is between 0 and 4 4 indicates that the two expressions are phonetically identical. LEFT charExpression intExpression Returns the leftmost characters specified by intExprssion from charExpression. LEN charExpression Returns the number of .