دالة SQL Server SUBSTRING ()
مثال
استخرج 3 أحرف من سلسلة ، بدءًا من الموضع 1:
SELECT SUBSTRING('SQL Tutorial', 1, 3) AS ExtractString;
التعريف والاستخدام
تستخرج الدالة SUBSTRING () بعض الأحرف من سلسلة.
بناء الجملة
SUBSTRING(string, start, length)
قيمه المعامل
Parameter | Description |
---|---|
string | Required. The string to extract from |
start | Required. The start position. The first position in string is 1 |
length | Required. The number of characters to extract. Must be a positive number |
تفاصيل تقنية
يعمل في: | SQL Server (بدءًا من 2008) ، قاعدة بيانات Azure SQL ، مستودع بيانات Azure SQL ، مستودع البيانات المتوازي |
---|
مزيد من الأمثلة
مثال
استخراج 5 أحرف من عمود "CustomerName" ، بدءًا من الموضع 1:
SELECT SUBSTRING(CustomerName, 1, 5) AS ExtractString
FROM Customers;
مثال
استخراج 100 حرف من سلسلة ، بدءًا من الموضع 1:
SELECT SUBSTRING('SQL Tutorial', 1, 100) AS ExtractString;