Using Functions phần 2
Số trang: 9
Loại file: pdf
Dung lượng: 47.58 KB
Lượt xem: 2
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
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)
Nội dung trích xuất từ tài liệu:
Using Functions phần 2You 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 aspecified length. The following example returns 1.23500, which is 1.23456 rounded tothree decimal places:SELECT ROUND(1.23456, 3);The next example passes a non-zero number as the third parameter to ROUND(), whichindicates that the number is to be truncated rather than rounded, as was done in theprevious 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 examplereturns 16.0:SELECT SQUARE(4);You use the SQRT() function to get the square root of a number. The following examplereturns 4.0:SELECT SQRT(16);Using String FunctionsThe string functions allow you to manipulate strings. For example, you can replacespecified characters in a string. Table 4.5 lists the string functions available in SQLServer. Table 4.5: STRING FUNCTIONSFUNCTION DESCRIPTIONASCII(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 (charExpression1, Returns the position of the characters specified by Table 4.5: STRING FUNCTIONSFUNCTION DESCRIPTIONcharExpression2 [, start ]) charExpression1 in charExpression2, starting at the optional position specified by start.DIFFERENCE (charExpression1, Returns the difference between the SOUNDEXcharExpression2) 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, Returns the leftmost characters specified byintExpression) intExprssion from charExpression.LEN(charExpression) Returns the number of characters in charExpression.LOWER(charExpression) Converts the characters in charExpression to lowercase and returns those characters.LTRIM(charExpression) Removes any leading spaces from the start of charExpression and returns the remaining characters.NCHAR(intExpression) Returns the Unicode character with the code specified by intExpression.PATINDEX(%pattern%, Returns the starting position of the first occurrencecharExpression) of pattern in charExpression. If pattern is not found then zeros are returned.REPLACE (charExpression1, Replaces all occurrences of charExpression2 incharExpression2, charExpression1 with charExpression3.charExpression3)QUOTENAME (charString [ , Returns a Unicode string with the delimitersquoteChar ]) specified by quoteChar added to make charString a valid delimited identifier.REPLICATE (charExpression, Repeats charExpression a total of intExpressionintExpression) times.REVERSE(charExpression) Reverses the characters in charExpression and returns those characters.RIGHT(charExpression, Returns the rightmost characters specified byintExpression) intExprssion from charExpression.RTRIM(charExpression) Removes any trailing spaces from the end of charExpression and returns the remaining characters.SOUNDEX(charExpression) Returns the four-character SOUNDEX code. You use this code to evaluate the phonetic similarity of Table 4.5: STRING FUNCTIONSFUNCTION DESCRIPTION two strings.SPACE(intExpression) Returns a string of repeated spaces for a total specified by intExpression.STR(floatExpression [ , length [ , Converts the number specified by floatExpression todecimal ] ]) characters; length specifies the total number of characters you want to see (including digits and spaces, plus the positive or negative sign and decimal point); decimal specifies the number of digits to the right of the decimal point. The number is rounded if necessary.STUFF (charExpression1, start, Deletes characters from charExpression1, starting atlength, charExpression2) the position specified by start for a total of length characters, and then inserts the characters specified by charExpression2.SUBSTRING(expression, start, Returns part of a character, binary, text, or imagelength) expression.UNICODE(nCharExpression) Returns the Unicode value for the first character of the nchar or nvarchar expression nCharExpression.UPPER(charExpression) Conver ...
Nội dung trích xuất từ tài liệu:
Using Functions phần 2You 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 aspecified length. The following example returns 1.23500, which is 1.23456 rounded tothree decimal places:SELECT ROUND(1.23456, 3);The next example passes a non-zero number as the third parameter to ROUND(), whichindicates that the number is to be truncated rather than rounded, as was done in theprevious 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 examplereturns 16.0:SELECT SQUARE(4);You use the SQRT() function to get the square root of a number. The following examplereturns 4.0:SELECT SQRT(16);Using String FunctionsThe string functions allow you to manipulate strings. For example, you can replacespecified characters in a string. Table 4.5 lists the string functions available in SQLServer. Table 4.5: STRING FUNCTIONSFUNCTION DESCRIPTIONASCII(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 (charExpression1, Returns the position of the characters specified by Table 4.5: STRING FUNCTIONSFUNCTION DESCRIPTIONcharExpression2 [, start ]) charExpression1 in charExpression2, starting at the optional position specified by start.DIFFERENCE (charExpression1, Returns the difference between the SOUNDEXcharExpression2) 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, Returns the leftmost characters specified byintExpression) intExprssion from charExpression.LEN(charExpression) Returns the number of characters in charExpression.LOWER(charExpression) Converts the characters in charExpression to lowercase and returns those characters.LTRIM(charExpression) Removes any leading spaces from the start of charExpression and returns the remaining characters.NCHAR(intExpression) Returns the Unicode character with the code specified by intExpression.PATINDEX(%pattern%, Returns the starting position of the first occurrencecharExpression) of pattern in charExpression. If pattern is not found then zeros are returned.REPLACE (charExpression1, Replaces all occurrences of charExpression2 incharExpression2, charExpression1 with charExpression3.charExpression3)QUOTENAME (charString [ , Returns a Unicode string with the delimitersquoteChar ]) specified by quoteChar added to make charString a valid delimited identifier.REPLICATE (charExpression, Repeats charExpression a total of intExpressionintExpression) times.REVERSE(charExpression) Reverses the characters in charExpression and returns those characters.RIGHT(charExpression, Returns the rightmost characters specified byintExpression) intExprssion from charExpression.RTRIM(charExpression) Removes any trailing spaces from the end of charExpression and returns the remaining characters.SOUNDEX(charExpression) Returns the four-character SOUNDEX code. You use this code to evaluate the phonetic similarity of Table 4.5: STRING FUNCTIONSFUNCTION DESCRIPTION two strings.SPACE(intExpression) Returns a string of repeated spaces for a total specified by intExpression.STR(floatExpression [ , length [ , Converts the number specified by floatExpression todecimal ] ]) characters; length specifies the total number of characters you want to see (including digits and spaces, plus the positive or negative sign and decimal point); decimal specifies the number of digits to the right of the decimal point. The number is rounded if necessary.STUFF (charExpression1, start, Deletes characters from charExpression1, starting atlength, charExpression2) the position specified by start for a total of length characters, and then inserts the characters specified by charExpression2.SUBSTRING(expression, start, Returns part of a character, binary, text, or imagelength) expression.UNICODE(nCharExpression) Returns the Unicode value for the first character of the nchar or nvarchar expression nCharExpression.UPPER(charExpression) Conver ...
Tìm kiếm theo từ khóa liên quan:
kĩ thuật lập trình công nghệ thông tin lập trình ngôn ngữ lập trình C Shark C# sybex - c.sharp database programming Using Functions phần 2Tài liệu liên quan:
-
52 trang 436 1 0
-
Top 10 mẹo 'đơn giản nhưng hữu ích' trong nhiếp ảnh
11 trang 324 0 0 -
74 trang 305 0 0
-
96 trang 301 0 0
-
Báo cáo thực tập thực tế: Nghiên cứu và xây dựng website bằng Wordpress
24 trang 294 0 0 -
Đồ án tốt nghiệp: Xây dựng ứng dụng di động android quản lý khách hàng cắt tóc
81 trang 288 0 0 -
Giáo trình Lập trình hướng đối tượng: Phần 2
154 trang 279 0 0 -
EBay - Internet và câu chuyện thần kỳ: Phần 1
143 trang 277 0 0 -
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 272 0 0 -
Bài thuyết trình Ngôn ngữ lập trình: Hệ điều hành Window Mobile
30 trang 271 0 0