{"id":40596,"date":"2025-11-05T06:59:35","date_gmt":"2025-11-05T06:59:35","guid":{"rendered":"http:\/\/www.withdata.com\/blog\/?p=40596"},"modified":"2025-11-05T07:13:41","modified_gmt":"2025-11-05T07:13:41","slug":"convert-sql-insert-statement-to-sql-update-statement","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/datafileconverter\/convert-sql-insert-statement-to-sql-update-statement.html","title":{"rendered":"Convert SQL Insert Statement To SQL Update Statement"},"content":{"rendered":"<p>Sometimes, you need to convert SQL insert statement to SQL update statement, you can use <a href=\"https:\/\/www.withdata.com\/data-file-converter\/\">Withdata DataFileConverter<\/a>, easy and fast.<\/p>\n<p>For example, you have a file employees_insert.sql, contains 2 SQL insert statements for SQL Server:<\/p>\n<pre>insert into employees (department_id,last_name,first_name,job_id,salary,email,manager_id,commission_pct,phone_number,employee_id,hire_date) \r\n  values (90,'King','Steven','AD_PRES',24000,'SKING',null,null,'515.123.4567',100,'6\/17\/1987') ;\r\ninsert into employees (department_id,last_name,first_name,job_id,salary,email,manager_id,commission_pct,phone_number,employee_id,hire_date) \r\n  values (90,'Kochhar','Neena','AD_VP',17000,'NKOCHHAR',100,null,'515.123.4568',101,'9\/21\/1989') ;\r\n<\/pre>\n<p>Use DataFileConverter, start a new task, and choose &#8220;From&#8221; &#8220;File&#8221; &#8220;SQL&#8221;, &#8220;To&#8221; &#8220;File&#8221; &#8220;SQL&#8221;.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/datafileconverter\/sql-to-sql.png\" alt=\"New Convert SQL Task\" width=\"802\" height=\"592\" style=\"max-width:100%;height:auto;display:block;\" \/><\/p>\n<p>1. Choose source SQL insert statement file.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/datafileconverter\/sql-convert-source-insert.png\" alt=\"SQL Insert to Update - Sourcee\" width=\"722\" height=\"572\" style=\"max-width:100%;height:auto;display:block;\" \/><\/p>\n<p>2. Choose &#8220;SQL Server&#8221; in &#8220;DBType&#8221;; Choose &#8220;Update&#8221; in &#8220;Convert Mode&#8221;; Set &#8220;By Key&#8221; to primary key, or unique index (include\u00a0Multiple-Column index).<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/datafileconverter\/sql-convert-target-update.png\" alt=\"SQL\" width=\"722\" height=\"572\" style=\"max-width:100%;height:auto;display:block;\" loading=\"lazy\" decoding=\"async\" \/><\/p>\n<p>3. See summary, click &#8220;Next&#8221;, then click &#8220;OK&#8221; to confirm.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/datafileconverter\/sql-convert-summary-update.png\" alt=\"SQL Insert to Update - Summary\" width=\"722\" height=\"572\" style=\"max-width:100%;height:auto;display:block;\" loading=\"lazy\" decoding=\"async\" \/><\/p>\n<p>4. See converting, and then click &#8220;View&#8221; to see output &#8220;Update&#8221; SQL.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/datafileconverter\/sql-convert-create-update.png\" alt=\"SQL Insert to Update - Convert\" width=\"722\" height=\"572\" style=\"max-width:100%;height:auto;display:block;\" loading=\"lazy\" decoding=\"async\" \/><\/p>\n<p>The output &#8220;Update&#8221; SQL:<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/datafileconverter\/sql-convert-view-update.png\" alt=\"SQL Insert to Update - View\" width=\"722\" height=\"572\" style=\"max-width:100%;height:auto;display:block;\" loading=\"lazy\" decoding=\"async\" \/><\/p>\n<p>The output &#8220;Update&#8221; SQL is for SQL Server:<\/p>\n<pre>update employees set department_id=90,last_name='King',first_name='Steven',job_id='AD_PRES',salary=24000,email='SKING',manager_id=null,commission_pct=null,phone_number='515.123.4567',hire_date='6\/17\/1987'\r\nwhere employee_id=100;\r\nupdate employees set department_id=90,last_name='Kochhar',first_name='Neena',job_id='AD_VP',salary=17000,email='NKOCHHAR',manager_id=100,commission_pct=null,phone_number='515.123.4568',hire_date='9\/21\/1989'\r\nwhere employee_id=101;\r\n<\/pre>\n<p>You can convert for other database also, just choose other &#8220;DBType&#8221;:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/datafileconverter\/sql-convert-dbtype.png\" alt=\"SQL Insert to Update - DBType\" width=\"549\" height=\"240\" style=\"max-width:100%;height:auto;display:block;\" loading=\"lazy\" decoding=\"async\" \/><\/p>\n<p>And it will create &#8220;Update&#8221; SQL for the &#8220;DBType&#8221;, like DB2:<\/p>\n<pre>update EMPLOYEES set DEPARTMENT_ID=90,LAST_NAME='King',FIRST_NAME='Steven',JOB_ID='AD_PRES',SALARY=24000,EMAIL='SKING',MANAGER_ID=null,COMMISSION_PCT=null,PHONE_NUMBER='515.123.4567',HIRE_DATE=TIMESTAMP_FORMAT('6\/17\/1987','MM\/DD\/YYYY')\r\nwhere EMPLOYEE_ID=100;\r\nupdate EMPLOYEES set DEPARTMENT_ID=90,LAST_NAME='Kochhar',FIRST_NAME='Neena',JOB_ID='AD_VP',SALARY=17000,EMAIL='NKOCHHAR',MANAGER_ID=100,COMMISSION_PCT=null,PHONE_NUMBER='515.123.4568',HIRE_DATE=TIMESTAMP_FORMAT('9\/21\/1989','MM\/DD\/YYYY')\r\nwhere EMPLOYEE_ID=101;\r\n<\/pre>\n<p>MySQL:<\/p>\n<pre>update `employees` set `department_id`=90,`last_name`='King',`first_name`='Steven',`job_id`='AD_PRES',`salary`=24000,`email`='SKING',`manager_id`=null,`commission_pct`=null,`phone_number`='515.123.4567',`hire_date`=str_to_date('6\/17\/1987','%m\/%d\/%Y')\r\nwhere `employee_id`=100;\r\nupdate `employees` set `department_id`=90,`last_name`='Kochhar',`first_name`='Neena',`job_id`='AD_VP',`salary`=17000,`email`='NKOCHHAR',`manager_id`=100,`commission_pct`=null,`phone_number`='515.123.4568',`hire_date`=str_to_date('9\/21\/1989','%m\/%d\/%Y')\r\nwhere `employee_id`=101;\r\n<\/pre>\n<p>Oracle:<\/p>\n<pre>update EMPLOYEES set DEPARTMENT_ID=90,LAST_NAME='King',FIRST_NAME='Steven',JOB_ID='AD_PRES',SALARY=24000,EMAIL='SKING',MANAGER_ID=null,COMMISSION_PCT=null,PHONE_NUMBER='515.123.4567',HIRE_DATE=to_date('6\/17\/1987','MM\/DD\/YYYY')\r\nwhere EMPLOYEE_ID=100;\r\nupdate EMPLOYEES set DEPARTMENT_ID=90,LAST_NAME='Kochhar',FIRST_NAME='Neena',JOB_ID='AD_VP',SALARY=17000,EMAIL='NKOCHHAR',MANAGER_ID=100,COMMISSION_PCT=null,PHONE_NUMBER='515.123.4568',HIRE_DATE=to_date('9\/21\/1989','MM\/DD\/YYYY')\r\nwhere EMPLOYEE_ID=101;\r\n<\/pre>\n<p>PostgreSQL:<\/p>\n<pre>update employees set department_id=90,last_name='King',first_name='Steven',job_id='AD_PRES',salary=24000,email='SKING',manager_id=null,commission_pct=null,phone_number='515.123.4567',hire_date=to_timestamp('6\/17\/1987','MM\/DD\/YYYY')\r\nwhere employee_id=100;\r\nupdate employees set department_id=90,last_name='Kochhar',first_name='Neena',job_id='AD_VP',salary=17000,email='NKOCHHAR',manager_id=100,commission_pct=null,phone_number='515.123.4568',hire_date=to_timestamp('9\/21\/1989','MM\/DD\/YYYY')\r\nwhere employee_id=101;\r\n<\/pre>\n<p>SQLite:<\/p>\n<pre>update [employees] set [department_id]=90,[last_name]='King',[first_name]='Steven',[job_id]='AD_PRES',[salary]=24000,[email]='SKING',[manager_id]=null,[commission_pct]=null,[phone_number]='515.123.4567',[hire_date]='1987-06-17'\r\nwhere [employee_id]=100;\r\nupdate [employees] set [department_id]=90,[last_name]='Kochhar',[first_name]='Neena',[job_id]='AD_VP',[salary]=17000,[email]='NKOCHHAR',[manager_id]=100,[commission_pct]=null,[phone_number]='515.123.4568',[hire_date]='1989-09-21'\r\nwhere [employee_id]=101;\r\n<\/pre>\n<p>See also:<br \/>\n<a href=\"https:\/\/www.withdata.com\/tools\/file\/export-to-sql\">Export databases data to SQL files<\/a><br \/>\n<a href=\"https:\/\/www.withdata.com\/tools\/file\/convert-for-sql\">Convert data between SQL and other file types<\/a><br \/>\n<a href=\"https:\/\/www.withdata.com\/tools\/file\/import-from-sql\">Import data from SQL files to databases<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes, you need to convert SQL insert statement to SQL update statement, you can use Withdata DataFileConverter, easy and fast. For example, you have a file employees_insert.sql, contains 2 SQL insert statements for SQL Server: insert into employees (department_id,last_name,first_name,job_id,salary,email,manager_id,commission_pct,phone_number,employee_id,hire_date) values (90,&#8217;King&#8217;,&#8217;Steven&#8217;,&#8217;AD_PRES&#8217;,24000,&#8217;SKING&#8217;,null,null,&#8217;515.123.4567&#8242;,100,&#8217;6\/17\/1987&#8242;) ; insert into employees (department_id,last_name,first_name,job_id,salary,email,manager_id,commission_pct,phone_number,employee_id,hire_date) values (90,&#8217;Kochhar&#8217;,&#8217;Neena&#8217;,&#8217;AD_VP&#8217;,17000,&#8217;NKOCHHAR&#8217;,100,null,&#8217;515.123.4568&#8242;,101,&#8217;9\/21\/1989&#8242;) ; Use DataFileConverter, start a new task, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1477],"tags":[13288,67,13289,2561],"class_list":["post-40596","post","type-post","status-publish","format-standard","hentry","category-datafileconverter","tag-insert","tag-sql","tag-sql-convert","tag-update"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/40596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/comments?post=40596"}],"version-history":[{"count":4,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/40596\/revisions"}],"predecessor-version":[{"id":40600,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/40596\/revisions\/40600"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=40596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=40596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=40596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}