{"id":18630,"date":"2022-04-06T06:10:00","date_gmt":"2022-04-06T04:10:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=18630"},"modified":"2022-11-28T12:01:46","modified_gmt":"2022-11-28T11:01:46","slug":"update-same-column-another-line-sql","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/","title":{"rendered":"Update the same column of another line with SQL Server"},"content":{"rendered":"\n<h4 class=\"has-text-align-center wp-block-heading\" id=\"h-how-to-update-the-same-column-in-the-same-table-of-another-line-with-sql-server\"><strong><em>How to update the same column in the same table of another line with SQL Server?<\/em><\/strong><\/h4>\n\n\n\n<p>Example of code to update the same SQL Server column on another line, on the same table. This row must be identified by another key, a simple UPDATE query of this type is not enough. Indeed, this query updates all rows with this key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A simple SQL Server update query updates all rows<\/h2>\n\n\n\n<p>Indeed, a standard query with the SQL <a href=\"https:\/\/en.wikipedia.org\/wiki\/Update_(SQL)\" target=\"_blank\" rel=\"noreferrer noopener\">UPDATE<\/a> command is not enough, because it updates all rows identified by the key or the filter, with the target value. Including the row with the source value. It is logical, because nothing is used to distinguish different lines in 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=\"\">-- This query does not work because it is a simple SQL update\nUPDATE MyTable\nSET MyField1 = 'Value'\nWHERE MyKeyField = 'My Key';\n<\/pre>\n\n\n\n<p>So, to update the field with SQL Server, identify the tuple that contains the other value and then retrieve the value. This tutorial shows how to update a field from the value contained in another row of the same column, identified by a key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create the table to update beforehand<\/h2>\n\n\n\n<p>Create beforehand the example table, CUSTOMERS, whose full script is available on this tutorial, <a href=\"https:\/\/expert-only.com\/en\/t-sql\/create-table-sql-server\/\">create the table of customers under SQL Server<\/a>.<\/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=\"\">-- Test if the table CUSTOMERS already exists\n-- And delete it if necessary\nIF EXISTS(\n   SELECT 1 FROM sys.objects\n   WHERE  object_id = object_id(N'[dbo].[CUSTOMERS]')\n      AND type in (N'U')\n)\nDROP TABLE [dbo].[CUSTOMERS]\nGO\n\n-- Create the CUSTOMERS table with the column NAME declared as UNIQUE\n-- The UNIQUE keyword defines the column with a unique value\n-- Inserting two customers with the same name is therefore impossible\nCREATE TABLE [dbo].[CUSTOMERS] (\n   [CLIENTID] int IDENTITY(1,1),\n   [NAME] nvarchar(20) UNIQUE,\n   [CITY] nvarchar(20)\n)\nGO\n\n-- Insert data for manipulation examples\nINSERT INTO dbo.CUSTOMERS (NAME, CITY) VALUES ('MAMMADOU', 'Lyon');\nINSERT INTO dbo.CUSTOMERS (NAME, CITY) VALUES ('SERGEI', 'Lyon');\nINSERT INTO dbo.CUSTOMERS (NAME, CITY) VALUES ('CHRISTOPHE', 'Paris');\n<\/pre>\n\n\n\n<p>Once the table is created in the database and the lines are inserted, check its content with a simple SELECT 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=\"\">-- Check updated rows\nSELECT *\nFROM dbo.CUSTOMERS;<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"680\" height=\"360\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/11\/t-sql-update-same-column-from-different-line-source-table.jpg\" alt=\"Select data from the SQL Server table data before the update\" class=\"wp-image-18641\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/11\/t-sql-update-same-column-from-different-line-source-table.jpg 680w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/11\/t-sql-update-same-column-from-different-line-source-table-300x159.jpg 300w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/11\/t-sql-update-same-column-from-different-line-source-table-678x360.jpg 678w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><figcaption class=\"wp-element-caption\"><strong>Select data from the SQL Server table data before the update<\/strong><\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Update the same column on another row in MS SQL<\/h2>\n\n\n\n<p>In order to retrieve the value of the field and update the column, use a query of this type. That is, you must use the same table twice with two different aliases:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>C1 clients: the alias of the table to be updated<\/li>\n\n\n\n<li>C2 clients: the alias of the same table to read the source value<\/li>\n<\/ul>\n\n\n\n<p>Run this UPDATE query with SQL Server 2016, but it works with other versions, such as SQL Server 2012 or SQL Server 2019.<\/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=\"\">-- Update the customer table\n-- I.e. the same column but in a different row\nUPDATE C1\nSET [CITY] = C2.[CITY]\nFROM\n  [dbo].[CUSTOMERS] C1 ,\n  [dbo].[CUSTOMERS] C2\nWHERE C1.[NAME] = 'MAMMADOU'\n  AND C2.[NAME] = 'CHRISTOPHE';\n\n\n-- Check updated rows\nSELECT *\nFROM dbo.CUSTOMERS;<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"680\" height=\"460\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/11\/t-sql-update-same-column-from-different-line-join-query.jpg\" alt=\"Query to Update the same column of another line with SQL Server in SSMS\" class=\"wp-image-18635\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/11\/t-sql-update-same-column-from-different-line-join-query.jpg 680w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/11\/t-sql-update-same-column-from-different-line-join-query-300x203.jpg 300w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/11\/t-sql-update-same-column-from-different-line-join-query-678x460.jpg 678w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><figcaption class=\"wp-element-caption\"><strong>Query to Update the same column of another line with SQL Server<\/strong><\/figcaption><\/figure><\/div>\n\n\n<p>Note that the client MAMMADOU is now attached to Paris. In a query with aliases and joins, the fields of the table are accessible only by using the alias such as C1.CITY. Or the full name dbo.CUSTOMERS.CITY to distinguish the two calls to the same table. Thus the rules apply as in a classic SQL query with a join.<\/p>\n\n\n\n<p>This tutorial on SQL Update query explains how, with a simple join, it is possible to retrieve the value of a row. Then how to use that value to update the same column but this time from a target row.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-sql-and-it-tutorials wp-block-embed-sql-and-it-tutorials\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"LBPsJCoEvX\"><a href=\"https:\/\/expert-only.com\/en\/t-sql\/insert-or-update-with-sql-server\/\">Insert or Update with SQL Server (Upsert)<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Insert or Update with SQL Server (Upsert)&#8221; &#8212; SQL and IT Tutorials\" src=\"https:\/\/expert-only.com\/en\/t-sql\/insert-or-update-with-sql-server\/embed\/#?secret=JvyuxsdXUy#?secret=LBPsJCoEvX\" data-secret=\"LBPsJCoEvX\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">T-SQL tutorials to manage objects<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/expert-only.com\/en\/manage-sql-server-tables\/\">How to manage SQL Server tables ?<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/expert-only.com\/en\/t-sql\/check-if-table-exists-in-sql-server\/\">Check if table exists in SQL Server<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/expert-only.com\/en\/t-sql\/create-temporary-table-sql-server\/\">Create a temporary table with SQL Server<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>How to update the same column in the same table of another line with SQL Server? Example of code to update the same SQL Server column on another line, on the same table. This row must be identified by <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/\" title=\"Update the same column of another line with SQL Server\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":10934,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[454],"tags":[],"class_list":{"0":"post-18630","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>Update the same column of another line with SQL Server - T-SQL<\/title>\n<meta name=\"description\" content=\"To update the same column of another line, in the same SQL Server table, use a join query with two aliases to select the source and target.\" \/>\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\/update-same-column-another-line-sql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Update the same column of another line with SQL Server\" \/>\n<meta property=\"og:description\" content=\"To update the same column of another line, in the same SQL Server table, use a join query with two aliases to select the source and target.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL and IT Tutorials\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-06T04:10:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-28T11:01:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/white-office-desk-chair-0AEEF15FCE6_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\/update-same-column-another-line-sql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"Update the same column of another line with SQL Server\",\"datePublished\":\"2022-04-06T04:10:00+00:00\",\"dateModified\":\"2022-11-28T11:01:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/\"},\"wordCount\":463,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/white-office-desk-chair-0AEEF15FCE6_1920x1080.jpg\",\"articleSection\":[\"T-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/\",\"url\":\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/\",\"name\":\"Update the same column of another line with SQL Server - T-SQL\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/white-office-desk-chair-0AEEF15FCE6_1920x1080.jpg\",\"datePublished\":\"2022-04-06T04:10:00+00:00\",\"dateModified\":\"2022-11-28T11:01:46+00:00\",\"description\":\"To update the same column of another line, in the same SQL Server table, use a join query with two aliases to select the source and target.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/white-office-desk-chair-0AEEF15FCE6_1920x1080.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/white-office-desk-chair-0AEEF15FCE6_1920x1080.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Update the same column of another line with SQL Server\"}]},{\"@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":"Update the same column of another line with SQL Server - T-SQL","description":"To update the same column of another line, in the same SQL Server table, use a join query with two aliases to select the source and target.","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\/update-same-column-another-line-sql\/","og_locale":"en_US","og_type":"article","og_title":"Update the same column of another line with SQL Server","og_description":"To update the same column of another line, in the same SQL Server table, use a join query with two aliases to select the source and target.","og_url":"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2022-04-06T04:10:00+00:00","article_modified_time":"2022-11-28T11:01:46+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/white-office-desk-chair-0AEEF15FCE6_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\/update-same-column-another-line-sql\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"Update the same column of another line with SQL Server","datePublished":"2022-04-06T04:10:00+00:00","dateModified":"2022-11-28T11:01:46+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/"},"wordCount":463,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/white-office-desk-chair-0AEEF15FCE6_1920x1080.jpg","articleSection":["T-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/","url":"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/","name":"Update the same column of another line with SQL Server - T-SQL","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/white-office-desk-chair-0AEEF15FCE6_1920x1080.jpg","datePublished":"2022-04-06T04:10:00+00:00","dateModified":"2022-11-28T11:01:46+00:00","description":"To update the same column of another line, in the same SQL Server table, use a join query with two aliases to select the source and target.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/white-office-desk-chair-0AEEF15FCE6_1920x1080.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/white-office-desk-chair-0AEEF15FCE6_1920x1080.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/t-sql\/update-same-column-another-line-sql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"Update the same column of another line with SQL Server"}]},{"@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\/18630","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=18630"}],"version-history":[{"count":0,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/18630\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/10934"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=18630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=18630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=18630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}