{"id":10717,"date":"2018-01-04T16:38:27","date_gmt":"2018-01-04T15:38:27","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/"},"modified":"2018-01-04T16:38:27","modified_gmt":"2018-01-04T15:38:27","slug":"sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/","title":{"rendered":"SQL Server 2017: TRIM not only a replacement of RTRIM and LTRIM"},"content":{"rendered":"<p>Last month, I present in the <a title=\"IT Tage 2017\" href=\"https:\/\/www.ittage.informatik-aktuell.de\/programm\/\" target=\"_blank\">IT-Tage 2017 in Frankfurt am Main<\/a>, a session about SQL Server 2017 overview.<br \/>\nDuring my session I made a demo on one of the new string T-SQL Commands: <strong>TRIM<\/strong>.<br \/>\nMy demo was very simple but I have also 2 very good questions.<\/p>\n<p>Before, I write about these question, I will show you what is TRIM.<br \/>\nThis function is a replacement of RTRIM and LTRIM to delete all space character before and after a string.<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">SELECT Name, RTRIM(LTRIM(Name)) as RLTrim_name, TRIM(Name) as Trim_name \nFROM [GoT].[dbo].[character-deaths2] Where Name like '%Aegon Targaryen%'\n\n<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-20286 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim01.jpg\" alt=\"trim01\" width=\"300\" height=\"275\" \/><\/a><\/p>\n<p>As you can see in the result of the query, TRIM() do the same as RTRIM(LTRIM()).<\/p>\n<p>But TRIM can also have a second usage and you can give a set of characters to be deleted and this use case is very useful.<\/p>\n<p>I made an example with this query to delete all A,n &amp; e from my precedent query:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">SELECT Name, TRIM('A,n,e' FROM Name)  as Trim_name, TRIM('A,n,e, ' FROM Name)  as Trim_name2\nFROM [GoT].[dbo].[character-deaths2] Where Name like '%Aegon Targaryen%'\n<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim02.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-20285 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim02.jpg\" alt=\"trim02\" width=\"300\" height=\"235\" \/><\/a><\/p>\n<p>In the result in the column Trim_name, I haven\u2019t what I expected\u2026 The problem is that all name values begin or end with several space characters.<br \/>\nI you look the Trim_name2 column and his associated query, you will see that I add a space character in the special characters\u2019 list.<br \/>\nThe first interesting question was:<\/p>\n<h2><em><strong>Can I use the char(xx) to define the character to be deleted?<\/strong><\/em><\/h2>\n<p>The ASCII code for a Space is 32 (20 in Hex). I test my query with char(32) like this:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">SELECT Name, TRIM(char(32) FROM Name)  as Trim_name \nFROM [GoT].[dbo].[character-deaths2] Where Name like '%Aegon Targaryen%'\n\n<\/pre>\n<p>I run the query\u2026<\/p>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim03.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-20284 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim03.jpg\" alt=\"trim03\" width=\"300\" height=\"240\" \/><\/a><br \/>\nYes, it\u2019s works! I can see that my result is without space character.<br \/>\nNow, I try with another character: char(65) \u00e0 A<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">SELECT Name, TRIM(char(32) FROM Name) as Trim_name , TRIM(char(65) FROM Name)  as Trim_name2 \nFROM [GoT].[dbo].[character-deaths2] Where Name like '%Aegon Targaryen%'<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim04.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-20283 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim04.jpg\" alt=\"trim04\" width=\"300\" height=\"157\" \/><\/a><\/p>\n<p>The result is what I expected with a deleted A at the beginning of the string.<br \/>\nMy last test is with both characters together in the same Trim function like this:<\/p>\n<pre class=\"brush: actionscript3; gutter: true; first-line: 1\">SELECT Name, TRIM(char(32),char(65) FROM Name) as Trim_name \nFROM [GoT].[dbo].[character-deaths2] Where Name like '%Aegon Targaryen%'<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim05.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-20282 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim05.jpg\" alt=\"trim05\" width=\"300\" height=\"107\" \/><\/a><\/p>\n<p>As you can see, I get an error. Incorrect syntax near the keyword &#8216;FROM&#8217;.<\/p>\n<p>This way is perhaps not the good way and I try another syntax with &#8216;char(32),char(65)&#8217;:<\/p>\n<pre class=\"brush: actionscript3; gutter: true; first-line: 1\">SELECT Name, TRIM('char(32),char(65)' FROM Name) as Trim_name\n\nFROM [GoT].[dbo].[character-deaths2] Where Name like '%Aegon Targaryen%'<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim06.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-20280 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim06.jpg\" alt=\"trim06\" width=\"300\" height=\"227\" \/><\/a><\/p>\n<p>The result is very strange. The character A at the beginning of the string is deleted but not the space character&#8230;<\/p>\n<p>This does not work! \ud83d\ude33<\/p>\n<p>As suggested by the comment of Jan (thanks to him), I use the CONCAT function with all characters that I want to delete:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">SELECT Name, TRIM(CONCAT(char(32), char(65)) FROM Name) as Trim_name \nFROM [GoT].[dbo].[character-deaths2] Where Name like '%Aegon Targaryen%'\n<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim12.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-20374 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim12.jpg\" alt=\"trim12\" width=\"300\" height=\"195\" \/><\/a><br \/>\nUsing CONCAT work fine!<\/p>\n<p>Let\u2019s go to the second question<br \/>\nThe second question was:<\/p>\n<h2><em><strong> Can I use a variable?<\/strong><\/em><\/h2>\n<p>My first test with a variable is very simple with the same characters set that I use in my demo:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">DECLARE @characters nvarchar(10);\nSET @characters= 'A,n,e, '\nSELECT Name, TRIM(@characters FROM Name)  as Trim_name FROM [GoT].[dbo].[character-deaths2] Where Name like '%Aegon Targaryen%'\n<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim08.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-20279 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim08.jpg\" alt=\"trim08\" width=\"300\" height=\"160\" \/><\/a><br \/>\nIt\u2019s working fine.<br \/>\nNow, I will try with the ASCII code.<\/p>\n<p>First I try with one characters :<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">DECLARE @characters nvarchar(10);\nSET @characters= char(32)\nSELECT Name, TRIM(@characters FROM Name)  as Trim_name FROM [GoT].[dbo].[character-deaths2] Where Name like '%Aegon Targaryen%'<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim11.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-20276 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim11.jpg\" alt=\"trim11\" width=\"300\" height=\"161\" \/><\/a><\/p>\n<p>I try with several characters.<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">DECLARE @characters nvarchar(10);\nSET @characters= 'char(32),char(65)'\nSELECT Name, TRIM(@characters FROM Name)  as Trim_name FROM [GoT].[dbo].[character-deaths2] Where Name like '%Aegon Targaryen%'\n<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim10.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-20277 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim10.jpg\" alt=\"trim10\" width=\"300\" height=\"162\" \/><\/a><br \/>\nAs you can see, the variable with several characters in ASCII code does not work.<\/p>\n<p>I also complete this test with the CONCAT function:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">DECLARE @characters nvarchar(10);\nSET @characters= CONCAT(char(32), char(65))\nSELECT Name, TRIM(@characters FROM Name)  as Trim_name FROM [GoT].[dbo].[character-deaths2] Where Name like '%Aegon Targaryen%'<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim13.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-20375 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/trim13.jpg\" alt=\"trim13\" width=\"300\" height=\"175\" \/><\/a><\/p>\n<p>It&#8217;s working fine!<\/p>\n<h2><strong>Summary<\/strong><\/h2>\n<p>To finish, I summarize all my tests in a little report:<\/p>\n<p>Using CONCAT with a variable with multiple characters in ASCII code<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-20275\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/ok-e1515083125737.png\" alt=\"ok\" width=\"16\" height=\"16\" \/><\/p>\n<table>\n<tbody>\n<tr>\n<td style=\"text-align: left\">Direct characters set<\/td>\n<td style=\"text-align: left\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-20275\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/ok-e1515083125737.png\" alt=\"ok\" width=\"16\" height=\"16\" \/><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Space character in ASCII code<\/td>\n<td style=\"text-align: left\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-20275\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/ok-e1515083125737.png\" alt=\"ok\" width=\"16\" height=\"16\" \/><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">One character in ASCII code<\/td>\n<td style=\"text-align: left\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-20275\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/ok-e1515083125737.png\" alt=\"ok\" width=\"16\" height=\"16\" \/><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Multiple characters in ASCII code<\/td>\n<td style=\"text-align: left\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-20274\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/nok-e1515083144284.png\" alt=\"nok\" width=\"16\" height=\"16\" \/><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Using CONCAT with multiple characters in ASCII code<\/td>\n<td style=\"text-align: left\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-20275\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/ok-e1515083125737.png\" alt=\"ok\" width=\"16\" height=\"16\" \/><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Variable with several characters<\/td>\n<td style=\"text-align: left\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-20275\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/ok-e1515083125737.png\" alt=\"ok\" width=\"16\" height=\"16\" \/><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Variable with one character in ASCII code<\/td>\n<td style=\"text-align: left\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-20275\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/ok-e1515083125737.png\" alt=\"ok\" width=\"16\" height=\"16\" \/><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Variable with multiple characters in ASCII code<\/td>\n<td style=\"text-align: left\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-20274\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/nok-e1515083144284.png\" alt=\"nok\" width=\"16\" height=\"16\" \/><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Using CONCAT with a variable with multiple characters in ASCII code<\/td>\n<td style=\"text-align: left\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-20275\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/ok-e1515083125737.png\" alt=\"ok\" width=\"16\" height=\"16\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last month, I present in the IT-Tage 2017 in Frankfurt am Main, a session about SQL Server 2017 overview. During my session I made a demo on one of the new string T-SQL Commands: TRIM. My demo was very simple but I have also 2 very good questions. Before, I write about these question, I [&hellip;]<\/p>\n","protected":false},"author":15,"featured_media":10730,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229,368,48],"tags":[49,98,51,1077],"type_dbi":[],"class_list":["post-10717","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database-administration-monitoring","category-development-performance","category-technology-survey","tag-microsoft","tag-sql","tag-sql-server","tag-sql-server-2017"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>SQL Server 2017: TRIM not only a replacement of RTRIM and LTRIM - dbi Blog<\/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:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server 2017: TRIM not only a replacement of RTRIM and LTRIM\" \/>\n<meta property=\"og:description\" content=\"Last month, I present in the IT-Tage 2017 in Frankfurt am Main, a session about SQL Server 2017 overview. During my session I made a demo on one of the new string T-SQL Commands: TRIM. My demo was very simple but I have also 2 very good questions. Before, I write about these question, I [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-04T15:38:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/nok-e1515083144284.png\" \/>\n\t<meta property=\"og:image:width\" content=\"16\" \/>\n\t<meta property=\"og:image:height\" content=\"16\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"St\u00e9phane Haby\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"St\u00e9phane Haby\" \/>\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:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/\"},\"author\":{\"name\":\"St\u00e9phane Haby\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0bfb7484ae81c8980fc2b11334f803b\"},\"headline\":\"SQL Server 2017: TRIM not only a replacement of RTRIM and LTRIM\",\"datePublished\":\"2018-01-04T15:38:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/\"},\"wordCount\":543,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/nok-e1515083144284.png\",\"keywords\":[\"Microsoft\",\"SQL\",\"SQL Server\",\"SQL Server 2017\"],\"articleSection\":[\"Database Administration &amp; Monitoring\",\"Development &amp; Performance\",\"Technology Survey\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/\",\"name\":\"SQL Server 2017: TRIM not only a replacement of RTRIM and LTRIM - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/nok-e1515083144284.png\",\"datePublished\":\"2018-01-04T15:38:27+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0bfb7484ae81c8980fc2b11334f803b\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/nok-e1515083144284.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/nok-e1515083144284.png\",\"width\":16,\"height\":16},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server 2017: TRIM not only a replacement of RTRIM and LTRIM\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0bfb7484ae81c8980fc2b11334f803b\",\"name\":\"St\u00e9phane Haby\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1123227ca39a5dca608c0f72d23cd1904fee29979749bbb3a485b9438436c553?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1123227ca39a5dca608c0f72d23cd1904fee29979749bbb3a485b9438436c553?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1123227ca39a5dca608c0f72d23cd1904fee29979749bbb3a485b9438436c553?s=96&d=mm&r=g\",\"caption\":\"St\u00e9phane Haby\"},\"description\":\"St\u00e9phane Haby has more than ten years of experience in Microsoft solutions. He is specialized in SQL Server technologies such as installation, migration, best practices, and performance analysis etc. He is also an expert in Microsoft Business Intelligence solutions such as SharePoint, SQL Server and Office. Futhermore, he has many years of .NET development experience in the banking sector and other industries. In France, he was one of the first people to have worked with Microsoft Team System. He has written several technical articles on this subject. St\u00e9phane Haby is Microsoft Most Valuable Professional (MVP) as well as Microsoft Certified Solutions Associate (MCSA) and\u00a0Microsoft Certified Solutions Expert (MCSE) for SQL Server 2012. He is also Microsoft Certified Technology Specialist (MCTS) and Microsoft Certified IT Professional (MCITP) for SQL Server 2008 as well as ITIL Foundation V3 certified. He holds a Engineer diploma in industrial computing and automation from France. His branch-related experience covers Chemicals &amp; Pharmaceuticals, Banking \\\/ Financial Services, and many other industries.\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/stephane-haby\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"SQL Server 2017: TRIM not only a replacement of RTRIM and LTRIM - dbi Blog","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:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server 2017: TRIM not only a replacement of RTRIM and LTRIM","og_description":"Last month, I present in the IT-Tage 2017 in Frankfurt am Main, a session about SQL Server 2017 overview. During my session I made a demo on one of the new string T-SQL Commands: TRIM. My demo was very simple but I have also 2 very good questions. Before, I write about these question, I [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/","og_site_name":"dbi Blog","article_published_time":"2018-01-04T15:38:27+00:00","og_image":[{"width":16,"height":16,"url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/nok-e1515083144284.png","type":"image\/png"}],"author":"St\u00e9phane Haby","twitter_card":"summary_large_image","twitter_misc":{"Written by":"St\u00e9phane Haby","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/"},"author":{"name":"St\u00e9phane Haby","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/d0bfb7484ae81c8980fc2b11334f803b"},"headline":"SQL Server 2017: TRIM not only a replacement of RTRIM and LTRIM","datePublished":"2018-01-04T15:38:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/"},"wordCount":543,"commentCount":0,"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/nok-e1515083144284.png","keywords":["Microsoft","SQL","SQL Server","SQL Server 2017"],"articleSection":["Database Administration &amp; Monitoring","Development &amp; Performance","Technology Survey"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/","url":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/","name":"SQL Server 2017: TRIM not only a replacement of RTRIM and LTRIM - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/nok-e1515083144284.png","datePublished":"2018-01-04T15:38:27+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/d0bfb7484ae81c8980fc2b11334f803b"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/nok-e1515083144284.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/nok-e1515083144284.png","width":16,"height":16},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-2017-trim-not-only-a-replacement-of-rtrim-and-ltrim\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"SQL Server 2017: TRIM not only a replacement of RTRIM and LTRIM"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/d0bfb7484ae81c8980fc2b11334f803b","name":"St\u00e9phane Haby","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1123227ca39a5dca608c0f72d23cd1904fee29979749bbb3a485b9438436c553?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1123227ca39a5dca608c0f72d23cd1904fee29979749bbb3a485b9438436c553?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1123227ca39a5dca608c0f72d23cd1904fee29979749bbb3a485b9438436c553?s=96&d=mm&r=g","caption":"St\u00e9phane Haby"},"description":"St\u00e9phane Haby has more than ten years of experience in Microsoft solutions. He is specialized in SQL Server technologies such as installation, migration, best practices, and performance analysis etc. He is also an expert in Microsoft Business Intelligence solutions such as SharePoint, SQL Server and Office. Futhermore, he has many years of .NET development experience in the banking sector and other industries. In France, he was one of the first people to have worked with Microsoft Team System. He has written several technical articles on this subject. St\u00e9phane Haby is Microsoft Most Valuable Professional (MVP) as well as Microsoft Certified Solutions Associate (MCSA) and\u00a0Microsoft Certified Solutions Expert (MCSE) for SQL Server 2012. He is also Microsoft Certified Technology Specialist (MCTS) and Microsoft Certified IT Professional (MCITP) for SQL Server 2008 as well as ITIL Foundation V3 certified. He holds a Engineer diploma in industrial computing and automation from France. His branch-related experience covers Chemicals &amp; Pharmaceuticals, Banking \/ Financial Services, and many other industries.","url":"https:\/\/www.dbi-services.com\/blog\/author\/stephane-haby\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/10717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=10717"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/10717\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media\/10730"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=10717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=10717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=10717"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=10717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}