Use of SUBSTRING Function in SQL:
(1) “SUBSTRING” function is used to extract characters from the string with defined length and position.
(2) Let’s take an example to extract the first two characters from Vendor Name as shown.
(3) Select the database in the SQL server and click on the “New Query” button as shown.
(4) After that new query editor opens as shown.
(5) After doing the above steps, write a query in the editor, as shown.
Source Code:
–//Use Of SUBSTRING Function Select [No_] AS [Vendor No.],[Name] AS [Vendor Name], SUBSTRING([Name],1,2)AS [SUBSTRING (extract first 2 characters)] Fromdbo.[CRONUS India Ltd_$Vendor$437dbf0e-84ff-417a-965d-ed2bb9650972] –//Use Of SUBSTRING Function |
(6) Then Execute or Press F5 to run the query and see the result as shown.