Lợi thế của các KHÁC BIỆT () chức năng này là nó mở rộng phạm vi tìm kiếm vượt ra ngoài các chữ cái đầu tiên. Vấn đề với chức năng này là nó muốn tính giá trị cho cả hai tham số Soundex, ngăn ngừa nó từ lợi dụng các giá trị được lưu trữ trước Soundex. | Part II Manipulating Data With Select Kennedy 3 Kennedy 3 Quinn 2 Kemper 1 Nicholson 0 The advantage of the DIFFERENCE function is that it broadens the search beyond the first letters. The problem with the function is that it wants to calculate the Soundex value for both parameters which prevents it from taking advantage of pre-stored Soundex values. Data-Type Conversion Functions Converting data from one data type to another data type is often handled automatically by SQL Server. Many of those conversions are implicit or automatic. Conversions that are explicit require a CAST or CONVERT function CAST Input as data type The ANSI standard SQL means of converting from one data type to another. Even when the conversion can be performed implicitly by SQL Server using the CAST function forces the desired data type. CAST is actually programmed slightly differently than a standard function. Rather than separate the two parameters with a comma as most functions do the data passed to the CAST function is followed by the as keyword and the requested output data type SELECT CAST Away AS NVARCHAR 5 AS Tom Hanks Result TOM HANKS AWAY Another example SELECT CAST 123 AS NVARCHAR 15 AS Int2String Result INT2STRING 123 CONVERT datatype expression style Returns a value converted to a different data type with optional formatting. The first parameter of this non-ANSI SQL function is the desired data type to be applied to the expression CONVERT data type expressionf style 222 Data Types Expressions and Scalar Functions 9 The style parameter usually refers to the optional date styles listed in Table 9-3. The style is applied to the output during conversion from datetime to a character-based data type or to the input during conversion from text to datetime. Generally the one- or two-digit style provides a two-digit year and its three-digit counterpart provides a four-digit year. For example style 1 provides 01 01 03 whereas style 101 provides 01 01 2003. The styles .