USEpubs; GOSELECTpub_id,SUBSTRING(logo,1,10)ASlogo,SUBSTRING(pr_info,1,10)ASpr_infoFROMpub_infoWHEREpub_id ='1756'; 结果集如下。 输出 pub_id logo pr_info ------ ---------------------- ---------- 1756 0x474946383961E30
USEpubs; GOSELECTpub_id,SUBSTRING(logo,1,10)ASlogo,SUBSTRING(pr_info,1,10)ASpr_infoFROMpub_infoWHEREpub_id ='1756'; 结果集如下。 输出 pub_id logo pr_info --- --- --- 1756 0x474946383961E3002500 This is sa 以下示例显示了文本和ntext数据的效果SUBSTRING。
The following example shows how to return the first 10 characters from each of atextandimagedata column in thepub_infotable of thepubsdatabase.textdata is returned asvarchar, andimagedata is returned asvarbinary. SQL USEpubs;SELECTpub_id,SUBSTRING(logo,1,10)ASlogo,SUBSTRING(pr_info,1,10)AS...
The following example shows how to return the second, third, and fourth characters of the string constant abcdef.SQL Αντιγραφή USE ssawPDW; SELECT TOP 1 SUBSTRING('abcdef', 2, 3) AS x FROM dbo.DimCustomer; Here is the result set....
The following example shows how to return only a part of a character string. From the Person table, this query returns the last name in one column with only the first initial in the second column. USE AdventureWorks2008R2; GO SELECT LastName, SUBSTRING(FirstName, 1, 1) AS Initial FROM ...
A. Using SUBSTRING with a character string The following example shows how to return only a part of a character string. From the Person table, this query returns the last name in one column with only the first initial in the second column. Copy USE AdventureWorks2012; GO SELECT LastName,...
CONSTRAINT ISOLATION SUBSTRING CONSTRAINTS JOIN SUM CONTINUE KEY SYSTEM_USER CONVERT LANGUAGE TABLE CORRESPONDING LAST TEMPORARY COUNT LEADING THEN CREATE LEFT TIME CROSS LEVEL TIMESTAMP CURRENT LIKE TIMEZONE_HOUR CURRENT_DATE LOCAL TIMEZONE_MINUTE CURRENT_TIME LOWER TO CURRENT_TIMESTAMP MATCH TRAILING CUR...
You can also use CONCAT function along with SUBSTRING function to produce a formatted output. mysql> select concat(substr(firstname,1,1),'. ',lastname) as EmpName from employees; +---+ | EmpName | +---+ | N. Davolio | | A. Smythe | | J...
It would be hard to teach, and I wanted you to learn something. Hopefully, you leaned some more about sorts, and also how to use PATINDEX, LEFT, and SUBSTRING to manipulate character values. Using user defined functions can solve a lot of problems, but beware that they can cause ...
However, if you convert these strings to Unicode and you perform the same comparison, the Unicode string N'a-c' is considered to be greater than N'ab', because the Unicode sorting rules use a word sort that ignores the hyphen. For more information, see SQL Server Collation Name. During ...