{"id":8067,"date":"2022-06-23T07:25:00","date_gmt":"2022-06-23T05:25:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=8067"},"modified":"2026-03-30T20:31:12","modified_gmt":"2026-03-30T18:31:12","slug":"sql-server-substring-function","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/","title":{"rendered":"How to use SQL Server SUBSTRING function?"},"content":{"rendered":"\n<h4 class=\"wp-block-heading has-text-align-center\" id=\"h-examples-of-sql-server-substring-function-to-split-a-text-column-or-a-variable-with-string-start-and-length-as-arguments\"><strong><em>Examples of SQL Server SUBSTRING function to split a text column or a variable with string, start and length as arguments.<\/em><\/strong><\/h4>\n\n\n\n<p>Find a few practical example queries that uses the SQL Server SUBSTRING function. This popular function is designed to cut text in T-SQL. <\/p>\n\n\n\n<p>It is definitely one the most used integrated text functions in T-SQL. To make the most of the information from this tutorial, let&#8217;s explore different use cases of the Substring() function with practical code examples.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#what-is-the-sql-server-substring-function\" >What is the SQL Server SUBSTRING function?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#use-case-1-cut-a-hardcoded-string\" >Use case 1 : Cut a hardcoded string<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#use-case-2-use-nested-sql-server-text-functions-including-substring\" >Use case 2 : Use nested SQL Server text functions including Substring<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#use-case-3-use-sql-server-sub-string-function-with-variables\" >Use case 3: Use SQL Server Sub String function with variables<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#use-case-4-extract-a-substring-from-the-beginning-of-a-column\" >Use Case 4 : Extract a substring from the beginning of a column<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#use-case-5-dynamically-extract-text-from-the-end-of-a-column\" >Use Case 5 : Dynamically extract text from the end of a column<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#use-case-6-extract-a-string-from-the-middle-of-a-sql-server-column\" >Use Case 6 : Extract a string from the middle of a SQL Server column<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#a-few-words-to-conclude-on-cutting-strings-with-sql-server\" >A few words to conclude on cutting strings with SQL Server<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-what-is-the-sql-server-substring-function\"><span class=\"ez-toc-section\" id=\"what-is-the-sql-server-substring-function\"><\/span>What is the SQL Server SUBSTRING function?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>First, the SUBSTRING function is equivalent to the SUBSTR function in non-Microsoft SQL languages. It simply allows you to split a string of characters using a start position and the length.<\/p>\n\n\n\n<p>Indeed, you must specify the starting position and the length of the extracted substring. The generic syntax of the function is as follows:<\/p>\n\n\n\n<p><code><strong>SUBSTRING(string, start, length)<\/strong><\/code><\/p>\n\n\n\n<p>The function uses 3 mandatory arguments which are the following:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>The string<\/strong>: The text to be split, the supported types are: characters, binary, text, ntext or the image type, it can of course be contained in a T-SQL variable.<\/li>\n\n\n\n<li><strong>The start position<\/strong>: i.e. from which character the slicing starts.<\/li>\n\n\n\n<li><strong>and the length<\/strong>: i.e. number of characters that the SubString <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/substring-transact-sql?view=sql-server-ver16\" target=\"_blank\" rel=\"noreferrer noopener\">function<\/a> returns.<\/li>\n<\/ol>\n\n\n\n<p>If one of the arguments is missing, the MS SQL system returns this error, on an English SQL Server version of the Microsoft RDBMS.<\/p>\n\n\n\n<p><em>&#8220;<strong>The substring function requires 3 argument(s).<\/strong>&#8220;<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-case-1-cut-a-hardcoded-string\"><span class=\"ez-toc-section\" id=\"use-case-1-cut-a-hardcoded-string\"><\/span>Use case 1 : Cut a hardcoded string<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This query returns the first 3 letters of this string : ABCDEFGH which contains 8 letters.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT SUBSTRING('ABCDEFGH', 1, 3) AS Result;\n-- Result displayed\nABC<\/pre>\n\n\n\n<p>This other example shows how to use the second argument, i.e. the start character), this time with the 0 value. The SQL database management system uses the larger of the numbers between start + length -1 and 0.<\/p>\n\n\n\n<p>So in our example : <strong>0+3-1 = 2<\/strong>. So only the first two letters of the alphabet are displayed.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT SUBSTRING('ABCDEFGH', 0, 3) AS Result;\n-- Result\nAB<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-case-2-use-nested-sql-server-text-functions-including-substring\"><span class=\"ez-toc-section\" id=\"use-case-2-use-nested-sql-server-text-functions-including-substring\"><\/span>Use case 2 : Use nested SQL Server text functions including Substring<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>It is of course possible to reuse the result directly in another text function. For example, using the system date from the server, called with GetDate() function combined with the Month argument.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The first query displays the name of the current month in full: <strong>August<\/strong><\/li>\n\n\n\n<li>The second one only returns the first 3 letters of the month: <strong>Aug<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT DATENAME(MONTH, GETDATE());\n-- Result\nAugust\nSELECT SUBSTRING(DATENAME(MONTH, GETDATE()), 1, 3) ;\n-- Result\nAug<\/pre>\n\n\n\n<p>Of course, integrated T-SQL date functions also allows to manipulate date and month name formats. For example to <a href=\"https:\/\/expert-only.com\/en\/t-sql\/display-month-name-sql-server\/\">display the month name in full letters using a simple query<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-sql-and-it-tutorials wp-block-embed-sql-and-it-tutorials\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"b73feY1fTj\"><a href=\"https:\/\/expert-only.com\/en\/t-sql\/how-to-display-month-name-in-sql-server\/\">How To Display Month Name In SQL Server ?<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;How To Display Month Name In SQL Server ?&#8221; &#8212; SQL and IT Tutorials\" src=\"https:\/\/expert-only.com\/en\/t-sql\/how-to-display-month-name-in-sql-server\/embed\/#?secret=Iv3YBrSaCH#?secret=b73feY1fTj\" data-secret=\"b73feY1fTj\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-case-3-use-sql-server-sub-string-function-with-variables\"><span class=\"ez-toc-section\" id=\"use-case-3-use-sql-server-sub-string-function-with-variables\"><\/span>Use case 3: Use SQL Server Sub String function with variables<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>For the 3rd use case, for more readability, modularity, and reusability, it is a good practice in IT development to use variables in the code.<\/p>\n\n\n\n<p>This code returns a variable with the name of the day in all caps with only the first 3 letters of the current day. It simply shows how combinations can allow more complex operations.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DECLARE @Day as NVARCHAR(20);\nSELECT  @Day = DATENAME(WEEKDAY, GETDATE());\nSELECT  UPPER(@Day); \n\n-- Result : day in all letters\nTHURSDAY\n\nSELECT UPPER(SUBSTRING(@Day, 1, 3));\n\n-- Result : three first letters of the weekday\nTHU<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-case-4-extract-a-substring-from-the-beginning-of-a-column\"><span class=\"ez-toc-section\" id=\"use-case-4-extract-a-substring-from-the-beginning-of-a-column\"><\/span>Use Case 4 : Extract a substring from the beginning of a column<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>One very common use case is to extract a substring from the very beginning of a string. <strong>It is then a prefix.<\/strong><\/p>\n\n\n\n<p>For example, we want to extract the first three characters of very name stroed in an Employee table. We can use the following T-SQL code to accomplish this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT SUBSTRING(name, 1, 3)\nFROM employee;<\/pre>\n\n\n\n<p>This will simply return a list of the first three characters of all employees.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-case-5-dynamically-extract-text-from-the-end-of-a-column\"><span class=\"ez-toc-section\" id=\"use-case-5-dynamically-extract-text-from-the-end-of-a-column\"><\/span>Use Case 5 : Dynamically extract text from the end of a column<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Another common use case of the SUBSTRING function is to <strong>extract a substring this time starting from the end of a string<\/strong>.<\/p>\n\n\n\n<p>Let&#8217;s say we have a table of product codes and we need to extract the last three characters of each code. But the product codes can have different legnths. We can use the following T-SQL code to extract the suffixes:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT SUBSTRING(code, LEN(code) - 2, 3)\nFROM products;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-case-6-extract-a-string-from-the-middle-of-a-sql-server-column\"><span class=\"ez-toc-section\" id=\"use-case-6-extract-a-string-from-the-middle-of-a-sql-server-column\"><\/span>Use Case 6 : Extract a string from the middle of a SQL Server column<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The SUBSTRING function can also be used to extract a text, dynamically from a specific character. Given a column with email addresses and we need to extract only the domain name from each address. <\/p>\n\n\n\n<p>It is again a suffix, but this time with a dynamic start, and a dynamic length too.<\/p>\n\n\n\n<p>expert-only<strong>@<\/strong>expert-only.com will become then expert-only.com<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT SUBSTRING(email, CHARINDEX('@', email) + 1, LEN(email) - CHARINDEX('@', email))\nFROM emails;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-a-few-words-to-conclude-on-cutting-strings-with-sql-server\"><span class=\"ez-toc-section\" id=\"a-few-words-to-conclude-on-cutting-strings-with-sql-server\"><\/span>A few words to conclude on cutting strings with SQL Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In conclusion, the SUBSTRING function is a powerful and very useful T-SQL function. It allows users to extract, replace within strings, and perform other useful operations on text and char columns in general.<\/p>\n\n\n\n<p>Hopefully those examples based on real life scemarios will help understand it and easily reproduce patterns on your own SQL projects!<\/p>\n\n\n\n<p>Text functions, like time functions, are really central in SQL development and therefore to our <a href=\"https:\/\/expert-only.com\/en\/t-sql\/\">SQL Server learning path<\/a>.<\/p>\n\n\n\n<p>Indeed, they help manipulate data and display different parts of dates in various formats. It is therefore  important to adapt the data types used in the database. Here is a tutorial on <a href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-string-longer-than-8000-chars\/\">how to manage long strings in T-SQL variables<\/a>.<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>If you like the content, please subscribe to our Youtube channel to help us grow<\/em><\/strong> :<\/p>\n\n\n\n<p class=\"has-text-align-center\"><a href=\"https:\/\/www.youtube.com\/@Expert-Only\" target=\"_blank\" rel=\"noreferrer noopener nofollow\"><strong><em>@Expert-Only on Youtube<\/em><\/strong><\/a><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-sql-and-it-tutorials wp-block-embed-sql-and-it-tutorials\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"owGEK1vEw0\"><a href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-string-longer-than-8000-chars\/\">SQL Server string longer than 8000 characters<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;SQL Server string longer than 8000 characters&#8221; &#8212; SQL and IT Tutorials\" src=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-string-longer-than-8000-chars\/embed\/#?secret=X5nHxVYZKC#?secret=owGEK1vEw0\" data-secret=\"owGEK1vEw0\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Examples of SQL Server SUBSTRING function to split a text column or a variable with string, start and length as arguments. Find a few practical example queries that uses the SQL Server SUBSTRING function. This popular function is designed <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/\" title=\"How to use SQL Server SUBSTRING function?\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":10944,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[454],"tags":[],"class_list":{"0":"post-8067","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-t-sql"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.7 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to use SQL Server SUBSTRING function? T-SQL<\/title>\n<meta name=\"description\" content=\"SQL Server SUBSTRING function examples to split a text column or variable, with string, start and length arguments.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use SQL Server SUBSTRING function?\" \/>\n<meta property=\"og:description\" content=\"SQL Server SUBSTRING function examples to split a text column or variable, with string, start and length arguments.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL and IT Tutorials\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-06-23T05:25:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-30T18:31:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/work-DE8FCB57747_1920x1080.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Expert-Only\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@expert_only\" \/>\n<meta name=\"twitter:site\" content=\"@expert_only\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Expert-Only\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"How to use SQL Server SUBSTRING function?\",\"datePublished\":\"2022-06-23T05:25:00+00:00\",\"dateModified\":\"2026-03-30T18:31:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/\"},\"wordCount\":851,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/work-DE8FCB57747_1920x1080.jpg\",\"articleSection\":[\"T-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/\",\"url\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/\",\"name\":\"How to use SQL Server SUBSTRING function? T-SQL\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/work-DE8FCB57747_1920x1080.jpg\",\"datePublished\":\"2022-06-23T05:25:00+00:00\",\"dateModified\":\"2026-03-30T18:31:12+00:00\",\"description\":\"SQL Server SUBSTRING function examples to split a text column or variable, with string, start and length arguments.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/work-DE8FCB57747_1920x1080.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/work-DE8FCB57747_1920x1080.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use SQL Server SUBSTRING function?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/expert-only.com\/en\/#website\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"name\":\"SQL and IT Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/expert-only.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/expert-only.com\/en\/#organization\",\"name\":\"Expert-Only\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"width\":381,\"height\":174,\"caption\":\"Expert-Only\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\",\"https:\/\/x.com\/expert_only\",\"https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\",\"name\":\"Expert-Only\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"caption\":\"Expert-Only\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to use SQL Server SUBSTRING function? T-SQL","description":"SQL Server SUBSTRING function examples to split a text column or variable, with string, start and length arguments.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/","og_locale":"en_US","og_type":"article","og_title":"How to use SQL Server SUBSTRING function?","og_description":"SQL Server SUBSTRING function examples to split a text column or variable, with string, start and length arguments.","og_url":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2022-06-23T05:25:00+00:00","article_modified_time":"2026-03-30T18:31:12+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/work-DE8FCB57747_1920x1080.jpg","type":"image\/jpeg"}],"author":"Expert-Only","twitter_card":"summary_large_image","twitter_creator":"@expert_only","twitter_site":"@expert_only","twitter_misc":{"Written by":"Expert-Only","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"How to use SQL Server SUBSTRING function?","datePublished":"2022-06-23T05:25:00+00:00","dateModified":"2026-03-30T18:31:12+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/"},"wordCount":851,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/work-DE8FCB57747_1920x1080.jpg","articleSection":["T-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/","url":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/","name":"How to use SQL Server SUBSTRING function? T-SQL","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/work-DE8FCB57747_1920x1080.jpg","datePublished":"2022-06-23T05:25:00+00:00","dateModified":"2026-03-30T18:31:12+00:00","description":"SQL Server SUBSTRING function examples to split a text column or variable, with string, start and length arguments.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/work-DE8FCB57747_1920x1080.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/work-DE8FCB57747_1920x1080.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-substring-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to use SQL Server SUBSTRING function?"}]},{"@type":"WebSite","@id":"https:\/\/expert-only.com\/en\/#website","url":"https:\/\/expert-only.com\/en\/","name":"SQL and IT Tutorials","description":"","publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/expert-only.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/expert-only.com\/en\/#organization","name":"Expert-Only","url":"https:\/\/expert-only.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","width":381,"height":174,"caption":"Expert-Only"},"image":{"@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ExpertOnlyCom\/","https:\/\/x.com\/expert_only","https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA"]},{"@type":"Person","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef","name":"Expert-Only","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","caption":"Expert-Only"}}]}},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/8067","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/comments?post=8067"}],"version-history":[{"count":5,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/8067\/revisions"}],"predecessor-version":[{"id":31097,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/8067\/revisions\/31097"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/10944"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=8067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=8067"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=8067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}