{"id":16558,"date":"2021-07-30T07:07:12","date_gmt":"2021-07-30T05:07:12","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/"},"modified":"2021-07-30T07:07:12","modified_gmt":"2021-07-30T05:07:12","slug":"sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/","title":{"rendered":"SQL Server: &#8220;Cannot resolve the collation conflict&#8221; in a Stored Procedure"},"content":{"rendered":"<p>This week I have a new little challenge by a customer.<br \/>\nBy executing a &#8220;standard&#8221; stored procedure, I have the error:<\/p>\n<p style=\"color: red\">Msg 468, Level 16, State 9, Procedure Get_logsessions, Line 56 [Batch Start Line 119]<br \/>\nCannot resolve the collation conflict between &#8220;Latin1_General_CI_AS&#8221; and &#8220;Latin1_General_CI_AS_KS_WS&#8221; in the equal to operation.<\/p>\n<p>The Stored Procedure named Get_Logsessions is to log all sessions running on the server in a table.<\/p>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict01.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-50917 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict01.png\" alt=\"\" width=\"300\" height=\"66\" \/><\/a><\/p>\n<p>Looking with the query I develop and present you in a precedent blog <a href=\"https:\/\/www.dbi-services.com\/blog\/sql-server-how-to-compare-server-and-database-collation\/\" target=\"_blank\" rel=\"noopener\">here.<\/a><\/p>\n<p>I can see that my database collation is not the same as the instance collation<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-50916 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict02.png\" alt=\"\" width=\"300\" height=\"51\" \/><\/a><\/p>\n<p>Here the script for the Procedure:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">CREATE PROCEDURE [dbo].[Get_logsessions]\nAS\nSET NOCOUNT ON\nIF OBJECT_ID(N'[dbo].[logsessions]') IS NULL\n\tBEGIN\n\t\tCREATE TABLE [dbo].[logsessions]\n\t\t\t(\n\t\t\t[clientip] varchar(48),\n\t\t\t[clientname] nvarchar(128)  ,\n\t\t\t[clientinterface] nvarchar(32) ,\n\t\t\t[app] nvarchar(128)  ,\n\t\t\t[auth] nvarchar(40) ,\n\t\t\t[login] nvarchar(128) ,\n\t\t\t[db] nvarchar(128),\n\t\t\t[firstaccess] [datetime] NULL,\n\t\t\t[lastaccess] [datetime] NULL,\n\t\t\t[count] bigint NULL\n\t\t\t)\n\tEND\n\nIF OBJECT_ID(N'tempdb..#sp_who2')  IS NOT NULL\n\tDROP TABLE #sp_who2\nIF OBJECT_ID(N'tempdb..#logsessions')  IS NOT NULL\n\tDROP TABLE #logsessions\n\n-- Use sp_who2 to be compatible with 2005 to replace [db] = db_name(b.database_id)\nCREATE TABLE #sp_who2 (SPID INT,Status VARCHAR(255) ,\n      Login  VARCHAR(255)  ,HostName  VARCHAR(255)  ,\n      BlkBy  VARCHAR(255) ,DBName  VARCHAR(255)  ,\n      Command VARCHAR(255)  ,CPUTime INT,\n      DiskIO INT,LastBatch VARCHAR(255)  ,\n      ProgramName VARCHAR(255) ,SPID2 INT,\n      REQUESTID INT)\n\nINSERT INTO #sp_who2 EXEC sp_who2\n\nSELECT DISTINCT\n\t[clientip] = a.client_net_address,\n\t[clientname] = b.host_name ,\n\t[clientinterface] = b.client_interface_name  ,\n\t[app] = b.program_name  ,\n\t[auth] = a.auth_scheme  ,\n\t[login] = b.login_name ,\n\t[db] = w.DBName  ,\n\t[firstaccess] = MIN(b.[login_time]),\n\t[lastaccess] = MAX(b.[login_time]),\n\t[count] = Count(*) \nINTO\n\t#logsessions\nFROM \n\tsys.dm_exec_connections a\n\tINNER JOIN sys.dm_exec_sessions b on a.session_id = b.session_id\n\tINNER JOIN  #sp_who2 w on w.SPID = b.session_id\nGROUP BY a.[client_net_address],b.[host_name] ,b.[client_interface_name],b.[program_name] ,a.[auth_scheme],b.[login_name],w.[DBName]\n\nUPDATE\n    b\nSET\n    b.[lastaccess] =  a.[lastaccess],\n\tb.[count] = b.[count] + 1\nFROM \n\t\t#logsessions a\n\t\tINNER JOIN [dbo].[logsessions] b\n\t\t\tON \ta.[clientip] = b.[clientip]  \n\t\t\tAND a.[clientname] = b.[clientname]  \n\t\t\tAND a.[clientinterface] = b.[clientinterface]  \n\t\t\tAND\ta.[app] = b.[app]  \n\t\t\tAND a.[auth] = b.[auth] \n\t\t\tAND a.[login] = b.[login]  \n\t\t\tAND a.[db] = b.[db] \n\tWHERE\n\t\tDATEDIFF(s,b.[lastaccess] ,a.[lastaccess]) &lt;&gt; 0\n\t\tAND\n\t\tDATEDIFF(s,b.[firstaccess] ,a.[firstaccess]) &lt;&gt; 0\n\t\tAND\n\t\tDATEDIFF(s,b.[firstaccess] ,a.[lastaccess]) &gt; 0\n\nINSERT INTO [dbo].[logsessions]\n        (\n\t\t [clientip]\n        ,[clientname]\n        ,[clientinterface]\n        ,[app]\n        ,[auth]\n        ,[login]\n        ,[db]\n\t\t,[firstaccess],\n\t\t[lastaccess],\n\t\t[count]\n\t\t)\n\t(\n\tSELECT\n\t\ta.[clientip],a.[clientname] ,a.[clientinterface],a.[app] ,a.[auth], a.[login],a.[db], a.[firstaccess],a.[lastaccess],a.count \n\tFROM #logsessions a\n\tLEFT JOIN [dbo].[logsessions] b\n\t\t\tON \ta.[clientip] = b.[clientip] \n\t\t\tAND a.[clientname] = b.[clientname]\n\t\t\tAND a.[clientinterface] = b.[clientinterface]  \n\t\t\tAND\ta.[app] = b.[app] \n\t\t\tAND a.[auth] = b.[auth]\n\t\t\tAND a.[login] = b.[login] \n\t\t\tAND a.[db] = b.[db]\n\tWHERE\n\t\tb.[clientip] IS NULL\n\t\t)\n\nDROP TABLE #logsessions\nDROP TABLE #sp_who2\n\nSET NOCOUNT OFF\nGO<\/pre>\n<p>If I comment the creation of the Stored Procedure and I execute the query , I see my collation conflict:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict03.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-50915 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict03.png\" alt=\"\" width=\"300\" height=\"233\" \/><\/a><\/p>\n<p>If I go to the line 67, I&#8217;m on the update command:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">UPDATE\n    b\nSET\n    b.[lastaccess] =  a.[lastaccess],\n\tb.[count] = b.[count] + 1\nFROM \n\t\t#logsessions a\n\t\tINNER JOIN [dbo].[logsessions] b\n\t\t\tON \ta.[clientip] = b.[clientip]  \n\t\t\tAND a.[clientname] = b.[clientname]  \n\t\t\tAND a.[clientinterface] = b.[clientinterface]  \n\t\t\tAND\ta.[app] = b.[app]  \n\t\t\tAND a.[auth] = b.[auth] \n\t\t\tAND a.[login] = b.[login]  \n\t\t\tAND a.[db] = b.[db] \n\tWHERE\n\t\tDATEDIFF(s,b.[lastaccess] ,a.[lastaccess])  0\n\t\tAND\n\t\tDATEDIFF(s,b.[firstaccess] ,a.[firstaccess])  0\n\t\tAND\n\t\tDATEDIFF(s,b.[firstaccess] ,a.[lastaccess]) &gt; 0\n<\/pre>\n<p>The conflict comes from the update from the table #logsessions to logsessions and the collation from the comparison between the varchar columns from each table in the join.<br \/>\nWhat can I do?<\/p>\n<p>I will simply aligned the collation for each column with<\/p>\n<p style=\"color: red\"><strong>COLLATE DATABASE_DEFAULT<\/strong><\/p>\n<p>My new update will be like this:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">UPDATE\n    b\nSET\n    b.[lastaccess] =  a.[lastaccess],\n\tb.[count] = b.[count] + 1\nFROM \n\t\t#logsessions a\n\t\tINNER JOIN [dbo].[logsessions] b \n\t\t\tON \ta.[clientip] = b.[clientip]\t\t\t\t\tCOLLATE DATABASE_DEFAULT\n\t\t\tAND a.[clientname] = b.[clientname]\t\t\t\tCOLLATE DATABASE_DEFAULT\n\t\t\tAND a.[clientinterface] = b.[clientinterface]\tCOLLATE DATABASE_DEFAULT\n\t\t\tAND\ta.[app] = b.[app]\t\t\t\t\t\t\tCOLLATE DATABASE_DEFAULT\n\t\t\tAND a.[auth] = b.[auth]\t\t\t\t\t\t\tCOLLATE DATABASE_DEFAULT\n\t\t\tAND a.[login] = b.[login]\t\t\t\t\t\tCOLLATE DATABASE_DEFAULT\n\t\t\tAND a.[db] = b.[db]\t\t\t\t\t\t\t\tCOLLATE DATABASE_DEFAULT\n\tWHERE\n\t\tDATEDIFF(s,b.[lastaccess] ,a.[lastaccess])  0\n\t\tAND\n\t\tDATEDIFF(s,b.[firstaccess] ,a.[firstaccess])  0\n\t\tAND\n\t\tDATEDIFF(s,b.[firstaccess] ,a.[lastaccess]) &gt; 0\n\n\n<\/pre>\n<p>And when I execute the script, no more conflict<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict04.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-50914 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict04.png\" alt=\"\" width=\"283\" height=\"300\" \/><\/a><\/p>\n<p>I do an alter Store Procedure and execute this new one:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict05.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-50913 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict05.png\" alt=\"\" width=\"300\" height=\"136\" \/><\/a><\/p>\n<p>Perfect no more collation conflict!<br \/>\nI think that is important to share with you this issue and hope you will win time if you need to resolve a similar case.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week I have a new little challenge by a customer. By executing a &#8220;standard&#8221; stored procedure, I have the error: Msg 468, Level 16, State 9, Procedure Get_logsessions, Line 56 [Batch Start Line 119] Cannot resolve the collation conflict between &#8220;Latin1_General_CI_AS&#8221; and &#8220;Latin1_General_CI_AS_KS_WS&#8221; in the equal to operation. The Stored Procedure named Get_Logsessions is&hellip;&nbsp;<\/p>\n","protected":false},"author":15,"featured_media":16563,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","neve_meta_reading_time":"","_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[4133],"tags":[],"class_list":["post-16558","post","type-post","status-publish","format-standard","has-post-thumbnail","category-database"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.9 (Yoast SEO v29.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>SQL Server: &quot;Cannot resolve the collation conflict&quot; in a Stored Procedure - dbi services 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-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server: &quot;Cannot resolve the collation conflict&quot; in a Stored Procedure\" \/>\n<meta property=\"og:description\" content=\"This week I have a new little challenge by a customer. By executing a &#8220;standard&#8221; stored procedure, I have the error: Msg 468, Level 16, State 9, Procedure Get_logsessions, Line 56 [Batch Start Line 119] Cannot resolve the collation conflict between &#8220;Latin1_General_CI_AS&#8221; and &#8220;Latin1_General_CI_AS_KS_WS&#8221; in the equal to operation. The Stored Procedure named Get_Logsessions is&hellip;&nbsp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi services Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/dbiservices\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-30T05:07:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict05.png\" \/>\n\t<meta property=\"og:image:width\" content=\"410\" \/>\n\t<meta property=\"og:image:height\" content=\"186\" \/>\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:creator\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:site\" content=\"@dbiservices\" \/>\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-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/\"},\"author\":{\"name\":\"St\u00e9phane Haby\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/7980252d7d7a521e285e7c66114cf82a\"},\"headline\":\"SQL Server: &#8220;Cannot resolve the collation conflict&#8221; in a Stored Procedure\",\"datePublished\":\"2021-07-30T05:07:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/\"},\"wordCount\":250,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Collation_conflict05.png\",\"articleSection\":[\"Database\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/\",\"name\":\"SQL Server: \\\"Cannot resolve the collation conflict\\\" in a Stored Procedure - dbi services Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Collation_conflict05.png\",\"datePublished\":\"2021-07-30T05:07:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Collation_conflict05.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Collation_conflict05.png\",\"width\":410,\"height\":186},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server: &#8220;Cannot resolve the collation conflict&#8221; in a Stored Procedure\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi services Blog\",\"description\":\"#BeSharing\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"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\":\"Organization\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\",\"name\":\"dbi services\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"width\":512,\"height\":512,\"caption\":\"dbi services\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/dbiservices\\\/\",\"https:\\\/\\\/x.com\\\/dbiservices\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/dbi-services\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/dbiservices\"],\"description\":\"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.\",\"email\":\"info@dbi-services.com\",\"telephone\":\"+41 32 422 96 00\",\"legalName\":\"dbi services SA\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/7980252d7d7a521e285e7c66114cf82a\",\"name\":\"St\u00e9phane Haby\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/STH_web-min-scaled.jpg\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/STH_web-min-scaled.jpg\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/STH_web-min-scaled.jpg\",\"caption\":\"St\u00e9phane Haby\"},\"description\":\"St\u00e9phane Haby has more than 20 years of experience in Microsoft solutions, specializing in the installation, migration, best practices, and performance analysis of Microsoft SQL Server, as well as Microsoft Business Intelligence solutions (SharePoint, Office) and .NET development for the banking sector. A former Microsoft Most Valuable Professional (MVP) and early adopter of Microsoft Team System in France, he has authored several technical articles. He holds Microsoft Certified Solutions Associate (MCSA) and Expert (MCSE) for SQL Server, MCTS, MCITP for SQL Server 2008, and ITIL V3 Foundation certifications. His industry experience covers chemicals and pharma, banking, and financial services.\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/stephane-haby\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"SQL Server: \"Cannot resolve the collation conflict\" in a Stored Procedure - dbi services 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-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server: \"Cannot resolve the collation conflict\" in a Stored Procedure","og_description":"This week I have a new little challenge by a customer. By executing a &#8220;standard&#8221; stored procedure, I have the error: Msg 468, Level 16, State 9, Procedure Get_logsessions, Line 56 [Batch Start Line 119] Cannot resolve the collation conflict between &#8220;Latin1_General_CI_AS&#8221; and &#8220;Latin1_General_CI_AS_KS_WS&#8221; in the equal to operation. The Stored Procedure named Get_Logsessions is&hellip;&nbsp;","og_url":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/","og_site_name":"dbi services Blog","article_publisher":"https:\/\/www.facebook.com\/dbiservices\/","article_published_time":"2021-07-30T05:07:12+00:00","og_image":[{"width":410,"height":186,"url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict05.png","type":"image\/png"}],"author":"St\u00e9phane Haby","twitter_card":"summary_large_image","twitter_creator":"@dbiservices","twitter_site":"@dbiservices","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-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/"},"author":{"name":"St\u00e9phane Haby","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/7980252d7d7a521e285e7c66114cf82a"},"headline":"SQL Server: &#8220;Cannot resolve the collation conflict&#8221; in a Stored Procedure","datePublished":"2021-07-30T05:07:12+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/"},"wordCount":250,"commentCount":0,"publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict05.png","articleSection":["Database"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/","url":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/","name":"SQL Server: \"Cannot resolve the collation conflict\" in a Stored Procedure - dbi services Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict05.png","datePublished":"2021-07-30T05:07:12+00:00","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict05.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/Collation_conflict05.png","width":410,"height":186},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-cannot-resolve-the-collation-conflict-in-a-stored-procedure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"SQL Server: &#8220;Cannot resolve the collation conflict&#8221; in a Stored Procedure"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi services Blog","description":"#BeSharing","publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"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":"Organization","@id":"https:\/\/www.dbi-services.com\/#organization","name":"dbi services","url":"https:\/\/www.dbi-services.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","width":512,"height":512,"caption":"dbi services"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/dbiservices\/","https:\/\/x.com\/dbiservices","https:\/\/www.linkedin.com\/company\/dbi-services\/","https:\/\/www.youtube.com\/user\/dbiservices"],"description":"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.","email":"info@dbi-services.com","telephone":"+41 32 422 96 00","legalName":"dbi services SA"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/7980252d7d7a521e285e7c66114cf82a","name":"St\u00e9phane Haby","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/08\/STH_web-min-scaled.jpg","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/08\/STH_web-min-scaled.jpg","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/08\/STH_web-min-scaled.jpg","caption":"St\u00e9phane Haby"},"description":"St\u00e9phane Haby has more than 20 years of experience in Microsoft solutions, specializing in the installation, migration, best practices, and performance analysis of Microsoft SQL Server, as well as Microsoft Business Intelligence solutions (SharePoint, Office) and .NET development for the banking sector. A former Microsoft Most Valuable Professional (MVP) and early adopter of Microsoft Team System in France, he has authored several technical articles. He holds Microsoft Certified Solutions Associate (MCSA) and Expert (MCSE) for SQL Server, MCTS, MCITP for SQL Server 2008, and ITIL V3 Foundation certifications. His industry experience covers chemicals and pharma, banking, and financial services.","url":"https:\/\/www.dbi-services.com\/blog\/author\/stephane-haby\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/16558","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=16558"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/16558\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media\/16563"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=16558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=16558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=16558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}