{"id":30739,"date":"2024-03-15T07:11:00","date_gmt":"2024-03-15T06:11:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=30739"},"modified":"2024-03-15T18:30:25","modified_gmt":"2024-03-15T17:30:25","slug":"find-duplicate-records-in-sql-server","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/","title":{"rendered":"How to Find Duplicate Records in SQL Server: A Comprehensive Guide"},"content":{"rendered":"\n<p><strong>Find duplicate records on one or multiple columns in SQL Server is a crucial task for maintaining data integrity and accuracy in your databases.<\/strong><\/p>\n\n\n\n<p>Duplicates can skew your analysis, leading to potentially costly business decisions. This guide provides a step-by-step approach to finding duplicate records in SQL Server using T-SQL queries, catering to various scenarios you might encounter.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#problem-duplicate-data-in-your-database\" >Problem: Duplicate Data in Your Database<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#solution-use-t-sql-queries-to-identify-duplicates\" >Solution: Use T-SQL Queries to Identify Duplicates<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#use-case-1-find-duplicate-records-based-on-a-single-column\" >Use Case 1: Find Duplicate Records Based on a Single Column<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#use-case-2-find-duplicate-records-based-on-multiple-columns\" >Use Case 2: Find Duplicate Records Based on Multiple Columns<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#removing-duplicates-while-retaining-one-unique-record\" >Removing Duplicates While Retaining One Unique Record<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#identifying-duplicates-across-multiple-tables\" >Identifying Duplicates Across Multiple Tables<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#find-duplicate-records-in-large-data-sets-using-hash-functions\" >Find Duplicate Records in Large Data Sets using Hash Functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#final-thoughts-on-detecting-duplicate-records\" >Final Thoughts on Detecting Duplicate Records<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-problem-duplicate-data-in-your-database\"><span class=\"ez-toc-section\" id=\"problem-duplicate-data-in-your-database\"><\/span>Problem: Duplicate Data in Your Database<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Duplicate records can arise from multiple sources, including human error during data entry, lack of unique constraints in database design, or as a result of data migration and integration processes. Such duplicates can compromise data quality and lead to incorrect analysis results.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-solution-use-t-sql-queries-to-identify-duplicates\"><span class=\"ez-toc-section\" id=\"solution-use-t-sql-queries-to-identify-duplicates\"><\/span>Solution: Use T-SQL Queries to Identify Duplicates<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>SQL Server&#8217;s <strong><a href=\"https:\/\/expert-only.com\/en\/t-sql-tutorial\/\">Transact-SQL language<\/a><\/strong> (T-SQL) offers robust but simple solutions to identify duplicate records. We will explore different methods to locate and display the duplicates, ensuring you can maintain a clean and reliable database.<\/p>\n\n\n\n<p>Before diving into the specifics, let&#8217;s create a sample table to illustrate how duplicates can be identified in SQL Server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-preparing-our-sample-table-with-duplicates\">Preparing Our Sample Table with Duplicates<\/h3>\n\n\n\n<p>Consider we have a sales records table named <code>SalesRecords<\/code> with the following structure:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/* Code provided by https:\/\/expert-only.com *\/\nCREATE TABLE SalesRecords (\n    SalesRecordID INT IDENTITY(1,1) PRIMARY KEY,\n    ProductID INT,\n    SaleDate DATE,\n    Quantity INT\n);\n<\/pre>\n\n\n\n<p>To add some sample data (including duplicates) into the <code>SalesRecords<\/code> table, use:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/* Code provided by https:\/\/expert-only.com *\/\nINSERT INTO SalesRecords (ProductID, SaleDate, Quantity)\nVALUES \n(1, '2022-01-01', 10),\n(2, '2022-01-02', 15),\n(1, '2022-01-01', 10), -- Duplicate\n(3, '2022-01-03', 20),\n(2, '2022-01-02', 15); -- Duplicate\n<\/pre>\n\n\n\n<p>Now, let&#8217;s move on to identifying these duplicate records.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-case-1-find-duplicate-records-based-on-a-single-column\"><span class=\"ez-toc-section\" id=\"use-case-1-find-duplicate-records-based-on-a-single-column\"><\/span>Use Case 1: Find Duplicate Records Based on a Single Column<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To find duplicates in a single column of the <code>SalesRecords<\/code> table, such as <code>ProductID<\/code>, you can use the following query:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/* Code provided by https:\/\/expert-only.com *\/\nSELECT\n   ProductID,\n   COUNT(*) AS NumerOfLines\nFROM   SalesRecords\nGROUP BY ProductID\nHAVING   COUNT(*) > 1;\n<\/pre>\n\n\n\n<p>This query lists products sold on multiple occasions, indicating potential duplicates based on the <code>ProductID<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-case-2-find-duplicate-records-based-on-multiple-columns\"><span class=\"ez-toc-section\" id=\"use-case-2-find-duplicate-records-based-on-multiple-columns\"><\/span>Use Case 2: Find Duplicate Records Based on Multiple Columns<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If duplicates are defined by a combination of columns, say <code>ProductID<\/code> and <code>SaleDate<\/code>, the query adjusts to group by these columns:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/* T-SQL Script by Expert-Only.com - https:\/\/expert-only.com\/ *\/ \nSELECT\n   ProductID,\n   SaleDate,\n   COUNT(*) AS NumerOfLines\nFROM SalesRecords\nGROUP BY ProductID, SaleDate\nHAVING COUNT(*) > 1;\n<\/pre>\n\n\n\n<p>This T-SQL script identifies records where the same product was sold on the same date, highlighting duplicates based on both the <code>ProductID<\/code> and <code>SaleDate<\/code>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"740\" height=\"360\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2024\/03\/find-duplicate-lines-using-sql-server-query.jpg\" alt=\"SSMS Screenshot: T-SQL Query to Find Duplicate Records in SQL Server\" class=\"wp-image-30741\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2024\/03\/find-duplicate-lines-using-sql-server-query.jpg 740w, https:\/\/expert-only.com\/wp-content\/uploads\/2024\/03\/find-duplicate-lines-using-sql-server-query-300x146.jpg 300w\" sizes=\"auto, (max-width: 740px) 100vw, 740px\" \/><figcaption class=\"wp-element-caption\"><em>SSMS Screenshot: T-SQL Query to Find Duplicate Records in SQL Server<\/em><\/figcaption><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\">About More Advanced Deduplication Techniques<\/h3>\n\n\n\n<p>Beyond the basics, managing duplicates in SQL Server can involve more sophisticated scenarios requiring advanced T-SQL techniques. Let&#8217;s explore a few common but more complex situations you might encounter in your database management efforts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"removing-duplicates-while-retaining-one-unique-record\"><\/span>Removing Duplicates While Retaining One Unique Record<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In some cases, you might not just want to identify duplicates but also remove them while keeping one instance of the duplicated record. This can be achieved using the <code>ROW_NUMBER()<\/code> function, which assigns a unique number to each row in the order you specify. By doing so, you can keep the first occurrence and delete the subsequent ones.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/* T-SQL code by https:\/\/expert-only.com\/ *\/\nWITH CTE_Duplicates AS (\n  SELECT *,\n         ROW_NUMBER() OVER(PARTITION BY ProductID, SaleDate ORDER BY SalesRecordID) AS RowNumber\n  FROM SalesRecords\n)\nDELETE FROM CTE_Duplicates WHERE RowNumber > 1;\n<\/pre>\n\n\n\n<p>This query uses a Common Table Expression (CTE) to partition the data by <code>ProductID<\/code> and <code>SaleDate<\/code>, orders the duplicates by <code>SalesRecordID<\/code>, and deletes all but the first instance of each duplicate set.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"identifying-duplicates-across-multiple-tables\"><\/span>Identifying Duplicates Across Multiple Tables<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes, duplicates are not confined to a single table but spread across multiple tables. Identifying these requires a JOIN operation to bring the relevant data together before applying duplicate detection logic.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/* T-SQL code by https:\/\/expert-only.com\/ *\/\nSELECT\n   a.ProductID,\n   a.SaleDate\nFROM SalesRecords a\nJOIN AnotherTable b\n   ON   a.ProductID = b.ProductID\n    AND a.SaleDate = b.SaleDate\nGROUP BY\n   a.ProductID,\n   a.SaleDate\nHAVING COUNT(*) > 1;\n<\/pre>\n\n\n\n<p>This example shows how to identify duplicates between <code>SalesRecords<\/code> and <code>AnotherTable<\/code> based on <code>ProductID<\/code> and <code>SaleDate<\/code>, which can be particularly useful when consolidating data from different sources.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"find-duplicate-records-in-large-data-sets-using-hash-functions\"><\/span>Find Duplicate Records in Large Data Sets using Hash Functions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>For very large data sets, performance can become an issue when identifying duplicates. One way to improve efficiency is by using hash functions to reduce the amount of data that needs to be compared. SQL Server&#8217;s <code>HASHBYTES<\/code> function can be used to create a hash of each row&#8217;s content, which can then be compared instead of the full row data.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/* T-SQL code by https:\/\/expert-only.com\/ *\/\nSELECT\n   HashValue,\n   COUNT(*) AS NumerOfLines\nFROM (\n  SELECT HASHBYTES('SHA1', CONCAT(ProductID, SaleDate, Quantity)) AS HashValue\n  FROM SalesRecords\n) AS HashedTable\nGROUP BY HashValue\nHAVING COUNT(*) > 1;\n<\/pre>\n\n\n\n<p>This approach computes a SHA1 hash of the concatenation of the <code>ProductID<\/code>, <code>SaleDate<\/code>, and <code>Quantity<\/code> for each record. By comparing these hashes, you can quickly identify duplicates, significantly improving the performance on large datasets.<\/p>\n\n\n\n<p>These advanced techniques extend the basic principles of duplicate detection in SQL Server, offering powerful tools for maintaining data quality in more complex scenarios.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-final-thoughts-on-detecting-duplicate-records\"><span class=\"ez-toc-section\" id=\"final-thoughts-on-detecting-duplicate-records\"><\/span>Final Thoughts on Detecting Duplicate Records<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We just learnt to find duplicate records in a given table in order to maintain the <a href=\"https:\/\/www.encyclopedia.com\/computing\/dictionaries-thesauruses-pictures-and-press-releases\/database-integrity\" target=\"_blank\" rel=\"noreferrer noopener\">data integrity<\/a> inside SQL Server databases. By leveraging T-SQL queries, you can effectively identify and handle duplicate data, ensuring your analyses remain accurate and reliable.<\/p>\n\n\n\n<p>Whether dealing with single-column duplicates or more complex scenarios involving multiple fields, SQL Server provides the tools you need to keep your data clean.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Find duplicate records on one or multiple columns in SQL Server is a crucial task for maintaining data integrity and accuracy in your databases. Duplicates can skew your analysis, leading to potentially costly business decisions. This guide provides a <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/\" title=\"How to Find Duplicate Records in SQL Server: A Comprehensive Guide\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":10819,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[454],"tags":[],"class_list":{"0":"post-30739","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-t-sql"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.7 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Find Duplicate Records in SQL Server ? T-SQL<\/title>\n<meta name=\"description\" content=\"Learn to find duplicate records in SQL Server with our T-SQL queries on single or multiple columns to maintain data integrity.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Find Duplicate Records in SQL Server: A Comprehensive Guide\" \/>\n<meta property=\"og:description\" content=\"Learn to find duplicate records in SQL Server with our T-SQL queries on single or multiple columns to maintain data integrity.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL and IT Tutorials\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-15T06:11:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-15T17:30:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Expert-Only\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@expert_only\" \/>\n<meta name=\"twitter:site\" content=\"@expert_only\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Expert-Only\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"How to Find Duplicate Records in SQL Server: A Comprehensive Guide\",\"datePublished\":\"2024-03-15T06:11:00+00:00\",\"dateModified\":\"2024-03-15T17:30:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/\"},\"wordCount\":711,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg\",\"articleSection\":[\"T-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/\",\"url\":\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/\",\"name\":\"How to Find Duplicate Records in SQL Server ? T-SQL\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg\",\"datePublished\":\"2024-03-15T06:11:00+00:00\",\"dateModified\":\"2024-03-15T17:30:25+00:00\",\"description\":\"Learn to find duplicate records in SQL Server with our T-SQL queries on single or multiple columns to maintain data integrity.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Find Duplicate Records in SQL Server: A Comprehensive Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/expert-only.com\/en\/#website\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"name\":\"SQL and IT Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/expert-only.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/expert-only.com\/en\/#organization\",\"name\":\"Expert-Only\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"width\":381,\"height\":174,\"caption\":\"Expert-Only\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\",\"https:\/\/x.com\/expert_only\",\"https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\",\"name\":\"Expert-Only\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"caption\":\"Expert-Only\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Find Duplicate Records in SQL Server ? T-SQL","description":"Learn to find duplicate records in SQL Server with our T-SQL queries on single or multiple columns to maintain data integrity.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"How to Find Duplicate Records in SQL Server: A Comprehensive Guide","og_description":"Learn to find duplicate records in SQL Server with our T-SQL queries on single or multiple columns to maintain data integrity.","og_url":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2024-03-15T06:11:00+00:00","article_modified_time":"2024-03-15T17:30:25+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg","type":"image\/jpeg"}],"author":"Expert-Only","twitter_card":"summary_large_image","twitter_creator":"@expert_only","twitter_site":"@expert_only","twitter_misc":{"Written by":"Expert-Only","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"How to Find Duplicate Records in SQL Server: A Comprehensive Guide","datePublished":"2024-03-15T06:11:00+00:00","dateModified":"2024-03-15T17:30:25+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/"},"wordCount":711,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg","articleSection":["T-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/","url":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/","name":"How to Find Duplicate Records in SQL Server ? T-SQL","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg","datePublished":"2024-03-15T06:11:00+00:00","dateModified":"2024-03-15T17:30:25+00:00","description":"Learn to find duplicate records in SQL Server with our T-SQL queries on single or multiple columns to maintain data integrity.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/t-sql\/find-duplicate-records-in-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to Find Duplicate Records in SQL Server: A Comprehensive Guide"}]},{"@type":"WebSite","@id":"https:\/\/expert-only.com\/en\/#website","url":"https:\/\/expert-only.com\/en\/","name":"SQL and IT Tutorials","description":"","publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/expert-only.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/expert-only.com\/en\/#organization","name":"Expert-Only","url":"https:\/\/expert-only.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","width":381,"height":174,"caption":"Expert-Only"},"image":{"@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ExpertOnlyCom\/","https:\/\/x.com\/expert_only","https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA"]},{"@type":"Person","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef","name":"Expert-Only","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","caption":"Expert-Only"}}]}},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/30739","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/comments?post=30739"}],"version-history":[{"count":3,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/30739\/revisions"}],"predecessor-version":[{"id":30749,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/30739\/revisions\/30749"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/10819"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=30739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=30739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=30739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}