{"id":121,"date":"2023-08-16T14:48:01","date_gmt":"2023-08-16T14:48:01","guid":{"rendered":"https:\/\/kourentzes.com\/konstantinos\/?p=121"},"modified":"2023-08-16T14:48:01","modified_gmt":"2023-08-16T14:48:01","slug":"t-sql-splitstring-function","status":"publish","type":"post","link":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/","title":{"rendered":"T-SQL SplitString function"},"content":{"rendered":"\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#212121\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"CREATE FUNCTION dbo.SplitString\n(\n   @String NVARCHAR(MAX),\n   @Delimiter NVARCHAR(10)\n)\nRETURNS @Result TABLE (Value NVARCHAR(MAX))\nAS\nBEGIN\n   DECLARE @Value NVARCHAR(MAX)\n   DECLARE @Pos INT\n\n   WHILE CHARINDEX(@Delimiter, @String) &gt; 0\n   BEGIN\n      SET @Pos = CHARINDEX(@Delimiter, @String)\n      SET @Value = SUBSTRING(@String, 1, @Pos - 1)\n      INSERT INTO @Result (Value) VALUES (@Value)\n      SET @String = SUBSTRING(@String, @Pos + LEN(@Delimiter), LEN(@String))\n   END\n\n   INSERT INTO @Result (Value) VALUES (@String)\n   \n   RETURN\nEND\n\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F78C6C\">CREATE<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">FUNCTION<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #82AAFF\">dbo<\/span><span style=\"color: #EEFFFF\">.SplitString<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">   @String <\/span><span style=\"color: #F78C6C\">NVARCHAR<\/span><span style=\"color: #EEFFFF\">(MAX),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">   @Delimiter <\/span><span style=\"color: #F78C6C\">NVARCHAR<\/span><span style=\"color: #EEFFFF\">(<\/span><span style=\"color: #F78C6C\">10<\/span><span style=\"color: #EEFFFF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F78C6C\">RETURNS<\/span><span style=\"color: #EEFFFF\"> @Result <\/span><span style=\"color: #F78C6C\">TABLE<\/span><span style=\"color: #EEFFFF\"> (<\/span><span style=\"color: #F78C6C\">Value<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">NVARCHAR<\/span><span style=\"color: #EEFFFF\">(MAX))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F78C6C\">AS<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F78C6C\">BEGIN<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">   <\/span><span style=\"color: #F78C6C\">DECLARE<\/span><span style=\"color: #EEFFFF\"> @Value <\/span><span style=\"color: #F78C6C\">NVARCHAR<\/span><span style=\"color: #EEFFFF\">(MAX)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">   <\/span><span style=\"color: #F78C6C\">DECLARE<\/span><span style=\"color: #EEFFFF\"> @Pos <\/span><span style=\"color: #C792EA\">INT<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">   <\/span><span style=\"color: #F78C6C\">WHILE<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #82AAFF\">CHARINDEX<\/span><span style=\"color: #EEFFFF\">(@Delimiter, @String) <\/span><span style=\"color: #89DDFF\">&gt;<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">   <\/span><span style=\"color: #F78C6C\">BEGIN<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">      <\/span><span style=\"color: #F78C6C\">SET<\/span><span style=\"color: #EEFFFF\"> @Pos <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #82AAFF\">CHARINDEX<\/span><span style=\"color: #EEFFFF\">(@Delimiter, @String)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">      <\/span><span style=\"color: #F78C6C\">SET<\/span><span style=\"color: #EEFFFF\"> @Value <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #82AAFF\">SUBSTRING<\/span><span style=\"color: #EEFFFF\">(@String, <\/span><span style=\"color: #F78C6C\">1<\/span><span style=\"color: #EEFFFF\">, @Pos <\/span><span style=\"color: #89DDFF\">-<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">1<\/span><span style=\"color: #EEFFFF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">      <\/span><span style=\"color: #F78C6C\">INSERT INTO<\/span><span style=\"color: #EEFFFF\"> @Result (<\/span><span style=\"color: #F78C6C\">Value<\/span><span style=\"color: #EEFFFF\">) <\/span><span style=\"color: #F78C6C\">VALUES<\/span><span style=\"color: #EEFFFF\"> (@Value)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">      <\/span><span style=\"color: #F78C6C\">SET<\/span><span style=\"color: #EEFFFF\"> @String <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #82AAFF\">SUBSTRING<\/span><span style=\"color: #EEFFFF\">(@String, @Pos <\/span><span style=\"color: #89DDFF\">+<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #82AAFF\">LEN<\/span><span style=\"color: #EEFFFF\">(@Delimiter), <\/span><span style=\"color: #82AAFF\">LEN<\/span><span style=\"color: #EEFFFF\">(@String))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">   <\/span><span style=\"color: #F78C6C\">END<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">   <\/span><span style=\"color: #F78C6C\">INSERT INTO<\/span><span style=\"color: #EEFFFF\"> @Result (<\/span><span style=\"color: #F78C6C\">Value<\/span><span style=\"color: #EEFFFF\">) <\/span><span style=\"color: #F78C6C\">VALUES<\/span><span style=\"color: #EEFFFF\"> (@String)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">   <\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">   <\/span><span style=\"color: #F78C6C\">RETURN<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F78C6C\">END<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>With this function in place, you can use it to split a string into rows like this:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#212121\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"SELECT Value\nFROM dbo.SplitString('Apple,Orange,Banana', ',');\n\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F78C6C\">SELECT<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">Value<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F78C6C\">FROM<\/span><span style=\"color: #EEFFFF\"> dbo.SplitString(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">Apple,Orange,Banana<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #EEFFFF\">, <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">,<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #EEFFFF\">);<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This will output:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#212121\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"value\n------\nApple\nOrange\nBanana\n\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F78C6C\">value<\/span><\/span>\n<span class=\"line\"><span style=\"color: #545454; font-style: italic\">------<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">Apple<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">Orange<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">Banana<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Please make sure to check the compatibility of your SQL Server version, as the <code>STRING_SPLIT()<\/code> function is available in SQL Server 2016 and later versions.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#212121\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"SELECT value\nFROM STRING_SPLIT('Apple,Orange,Banana', ',');\n\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F78C6C\">SELECT<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">value<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F78C6C\">FROM<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #82AAFF\">STRING_SPLIT<\/span><span style=\"color: #EEFFFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">Apple,Orange,Banana<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #EEFFFF\">, <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">,<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #EEFFFF\">);<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>With this function in place, you can use it to split a string into rows like this: This will output: Please make sure to check the compatibility of your SQL Server version, as the STRING_SPLIT() function is available in SQL Server 2016 and later versions.<\/p>\n","protected":false},"author":1,"featured_media":76,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[10],"tags":[45,43,52,42],"class_list":["post-121","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code-snipperts","tag-ms-sql-2","tag-sql","tag-string_split","tag-t-sql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>T-SQL SplitString function - konstantinos.kourentzes.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"T-SQL SplitString function - konstantinos.kourentzes.com\" \/>\n<meta property=\"og:description\" content=\"With this function in place, you can use it to split a string into rows like this: This will output: Please make sure to check the compatibility of your SQL Server version, as the STRING_SPLIT() function is available in SQL Server 2016 and later versions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/\" \/>\n<meta property=\"og:site_name\" content=\"konstantinos.kourentzes.com\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-16T14:48:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/kourentzes.com\/konstantinos\/wp-content\/uploads\/2023\/08\/emperor_kk_t-sql_0b4b8ca2-a098-42cb-9c5f-72cc553e2bc1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Konstantinos Kourentzes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@kkourentzes\" \/>\n<meta name=\"twitter:site\" content=\"@kkourentzes\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Konstantinos Kourentzes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/2023\\\/08\\\/16\\\/t-sql-splitstring-function\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/2023\\\/08\\\/16\\\/t-sql-splitstring-function\\\/\"},\"author\":{\"name\":\"Konstantinos Kourentzes\",\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/#\\\/schema\\\/person\\\/2693fb0ad7f7638a020431ffe372c822\"},\"headline\":\"T-SQL SplitString function\",\"datePublished\":\"2023-08-16T14:48:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/2023\\\/08\\\/16\\\/t-sql-splitstring-function\\\/\"},\"wordCount\":46,\"publisher\":{\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/#\\\/schema\\\/person\\\/2693fb0ad7f7638a020431ffe372c822\"},\"image\":{\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/2023\\\/08\\\/16\\\/t-sql-splitstring-function\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/emperor_kk_t-sql_0b4b8ca2-a098-42cb-9c5f-72cc553e2bc1.png\",\"keywords\":[\"ms sql\",\"sql\",\"string_split\",\"t-sql\"],\"articleSection\":[\"Code Snippets\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/2023\\\/08\\\/16\\\/t-sql-splitstring-function\\\/\",\"url\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/2023\\\/08\\\/16\\\/t-sql-splitstring-function\\\/\",\"name\":\"T-SQL SplitString function - konstantinos.kourentzes.com\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/2023\\\/08\\\/16\\\/t-sql-splitstring-function\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/2023\\\/08\\\/16\\\/t-sql-splitstring-function\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/emperor_kk_t-sql_0b4b8ca2-a098-42cb-9c5f-72cc553e2bc1.png\",\"datePublished\":\"2023-08-16T14:48:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/2023\\\/08\\\/16\\\/t-sql-splitstring-function\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/2023\\\/08\\\/16\\\/t-sql-splitstring-function\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/2023\\\/08\\\/16\\\/t-sql-splitstring-function\\\/#primaryimage\",\"url\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/emperor_kk_t-sql_0b4b8ca2-a098-42cb-9c5f-72cc553e2bc1.png\",\"contentUrl\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/emperor_kk_t-sql_0b4b8ca2-a098-42cb-9c5f-72cc553e2bc1.png\",\"width\":1024,\"height\":1024},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/2023\\\/08\\\/16\\\/t-sql-splitstring-function\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"T-SQL SplitString function\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/#website\",\"url\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/\",\"name\":\"kourentzes.com\\\/konstantinos\",\"description\":\"Konstantinos Kourentzes\",\"publisher\":{\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/#\\\/schema\\\/person\\\/2693fb0ad7f7638a020431ffe372c822\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/#\\\/schema\\\/person\\\/2693fb0ad7f7638a020431ffe372c822\",\"name\":\"Konstantinos Kourentzes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/kko.png\",\"url\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/kko.png\",\"contentUrl\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/kko.png\",\"width\":2835,\"height\":2268,\"caption\":\"Konstantinos Kourentzes\"},\"logo\":{\"@id\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/kko.png\"},\"description\":\"Konstantinos Kourentzes is a distinguished technologist and Enterprise Resource Planning (ERP) consultant renowned for his expertise in delivering cutting-edge technology solutions. Based in Marousi, Greece, he has a knack for seamlessly integrating data-driven systems, empowering businesses to streamline their operations and achieve peak efficiency. A fervent proponent of innovation, Konstantinos is committed to instigating revolutionary shifts within organizations. His approach revolves around delivering custom-tailored ERP solutions that seamlessly align with each business's distinctive requirements. This catalyzes enduring collaborations rooted in unwavering trust and tangible outcomes. With a background rooted in technology and a passion for optimizing business processes, Konstantinos is your go-to partner for harnessing the power of ERP systems to unlock operational excellence. Connect with Konstantinos on LinkedIn to explore how his technological insights can drive your business to new heights.\",\"sameAs\":[\"https:\\\/\\\/kourentzes.com\\\/konstantinos\",\"https:\\\/\\\/x.com\\\/kkourentzes\"],\"url\":\"https:\\\/\\\/kourentzes.com\\\/konstantinos\\\/index.php\\\/author\\\/administrator\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"T-SQL SplitString function - konstantinos.kourentzes.com","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:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/","og_locale":"en_US","og_type":"article","og_title":"T-SQL SplitString function - konstantinos.kourentzes.com","og_description":"With this function in place, you can use it to split a string into rows like this: This will output: Please make sure to check the compatibility of your SQL Server version, as the STRING_SPLIT() function is available in SQL Server 2016 and later versions.","og_url":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/","og_site_name":"konstantinos.kourentzes.com","article_published_time":"2023-08-16T14:48:01+00:00","og_image":[{"width":1024,"height":1024,"url":"https:\/\/kourentzes.com\/konstantinos\/wp-content\/uploads\/2023\/08\/emperor_kk_t-sql_0b4b8ca2-a098-42cb-9c5f-72cc553e2bc1.png","type":"image\/png"}],"author":"Konstantinos Kourentzes","twitter_card":"summary_large_image","twitter_creator":"@kkourentzes","twitter_site":"@kkourentzes","twitter_misc":{"Written by":"Konstantinos Kourentzes","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/#article","isPartOf":{"@id":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/"},"author":{"name":"Konstantinos Kourentzes","@id":"https:\/\/kourentzes.com\/konstantinos\/#\/schema\/person\/2693fb0ad7f7638a020431ffe372c822"},"headline":"T-SQL SplitString function","datePublished":"2023-08-16T14:48:01+00:00","mainEntityOfPage":{"@id":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/"},"wordCount":46,"publisher":{"@id":"https:\/\/kourentzes.com\/konstantinos\/#\/schema\/person\/2693fb0ad7f7638a020431ffe372c822"},"image":{"@id":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/#primaryimage"},"thumbnailUrl":"https:\/\/kourentzes.com\/konstantinos\/wp-content\/uploads\/2023\/08\/emperor_kk_t-sql_0b4b8ca2-a098-42cb-9c5f-72cc553e2bc1.png","keywords":["ms sql","sql","string_split","t-sql"],"articleSection":["Code Snippets"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/","url":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/","name":"T-SQL SplitString function - konstantinos.kourentzes.com","isPartOf":{"@id":"https:\/\/kourentzes.com\/konstantinos\/#website"},"primaryImageOfPage":{"@id":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/#primaryimage"},"image":{"@id":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/#primaryimage"},"thumbnailUrl":"https:\/\/kourentzes.com\/konstantinos\/wp-content\/uploads\/2023\/08\/emperor_kk_t-sql_0b4b8ca2-a098-42cb-9c5f-72cc553e2bc1.png","datePublished":"2023-08-16T14:48:01+00:00","breadcrumb":{"@id":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/#primaryimage","url":"https:\/\/kourentzes.com\/konstantinos\/wp-content\/uploads\/2023\/08\/emperor_kk_t-sql_0b4b8ca2-a098-42cb-9c5f-72cc553e2bc1.png","contentUrl":"https:\/\/kourentzes.com\/konstantinos\/wp-content\/uploads\/2023\/08\/emperor_kk_t-sql_0b4b8ca2-a098-42cb-9c5f-72cc553e2bc1.png","width":1024,"height":1024},{"@type":"BreadcrumbList","@id":"https:\/\/kourentzes.com\/konstantinos\/index.php\/2023\/08\/16\/t-sql-splitstring-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kourentzes.com\/konstantinos\/"},{"@type":"ListItem","position":2,"name":"T-SQL SplitString function"}]},{"@type":"WebSite","@id":"https:\/\/kourentzes.com\/konstantinos\/#website","url":"https:\/\/kourentzes.com\/konstantinos\/","name":"kourentzes.com\/konstantinos","description":"Konstantinos Kourentzes","publisher":{"@id":"https:\/\/kourentzes.com\/konstantinos\/#\/schema\/person\/2693fb0ad7f7638a020431ffe372c822"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kourentzes.com\/konstantinos\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/kourentzes.com\/konstantinos\/#\/schema\/person\/2693fb0ad7f7638a020431ffe372c822","name":"Konstantinos Kourentzes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kourentzes.com\/konstantinos\/wp-content\/uploads\/2022\/02\/kko.png","url":"https:\/\/kourentzes.com\/konstantinos\/wp-content\/uploads\/2022\/02\/kko.png","contentUrl":"https:\/\/kourentzes.com\/konstantinos\/wp-content\/uploads\/2022\/02\/kko.png","width":2835,"height":2268,"caption":"Konstantinos Kourentzes"},"logo":{"@id":"https:\/\/kourentzes.com\/konstantinos\/wp-content\/uploads\/2022\/02\/kko.png"},"description":"Konstantinos Kourentzes is a distinguished technologist and Enterprise Resource Planning (ERP) consultant renowned for his expertise in delivering cutting-edge technology solutions. Based in Marousi, Greece, he has a knack for seamlessly integrating data-driven systems, empowering businesses to streamline their operations and achieve peak efficiency. A fervent proponent of innovation, Konstantinos is committed to instigating revolutionary shifts within organizations. His approach revolves around delivering custom-tailored ERP solutions that seamlessly align with each business's distinctive requirements. This catalyzes enduring collaborations rooted in unwavering trust and tangible outcomes. With a background rooted in technology and a passion for optimizing business processes, Konstantinos is your go-to partner for harnessing the power of ERP systems to unlock operational excellence. Connect with Konstantinos on LinkedIn to explore how his technological insights can drive your business to new heights.","sameAs":["https:\/\/kourentzes.com\/konstantinos","https:\/\/x.com\/kkourentzes"],"url":"https:\/\/kourentzes.com\/konstantinos\/index.php\/author\/administrator\/"}]}},"_links":{"self":[{"href":"https:\/\/kourentzes.com\/konstantinos\/index.php\/wp-json\/wp\/v2\/posts\/121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kourentzes.com\/konstantinos\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kourentzes.com\/konstantinos\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kourentzes.com\/konstantinos\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kourentzes.com\/konstantinos\/index.php\/wp-json\/wp\/v2\/comments?post=121"}],"version-history":[{"count":1,"href":"https:\/\/kourentzes.com\/konstantinos\/index.php\/wp-json\/wp\/v2\/posts\/121\/revisions"}],"predecessor-version":[{"id":125,"href":"https:\/\/kourentzes.com\/konstantinos\/index.php\/wp-json\/wp\/v2\/posts\/121\/revisions\/125"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kourentzes.com\/konstantinos\/index.php\/wp-json\/wp\/v2\/media\/76"}],"wp:attachment":[{"href":"https:\/\/kourentzes.com\/konstantinos\/index.php\/wp-json\/wp\/v2\/media?parent=121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kourentzes.com\/konstantinos\/index.php\/wp-json\/wp\/v2\/categories?post=121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kourentzes.com\/konstantinos\/index.php\/wp-json\/wp\/v2\/tags?post=121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}