Fonction SQL Server SUBSTRING()
Exemple
Extrayez 3 caractères d'une chaîne, en commençant en position 1 :
SELECT SUBSTRING('SQL Tutorial', 1, 3) AS ExtractString;
Définition et utilisation
La fonction SUBSTRING() extrait certains caractères d'une chaîne.
Syntaxe
SUBSTRING(string, start, length)
Valeurs des paramètres
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 |
Détails techniques
Travaille dans: | SQL Server (à partir de 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse |
---|
Plus d'exemples
Exemple
Extrayez 5 caractères de la colonne "CustomerName", en commençant en position 1 :
SELECT SUBSTRING(CustomerName, 1, 5) AS ExtractString
FROM Customers;
Exemple
Extrayez 100 caractères d'une chaîne, en commençant à la position 1 :
SELECT SUBSTRING('SQL Tutorial', 1, 100) AS ExtractString;