﻿{"id":5339,"date":"2014-04-13T06:05:11","date_gmt":"2014-04-12T21:05:11","guid":{"rendered":"http:\/\/fujiitoshiki.com\/improvesociety\/?p=5339"},"modified":"2014-07-31T13:33:46","modified_gmt":"2014-07-31T04:33:46","slug":"how-to-bulk-insert-from-text-file-to-the-table-which-primary-key-is-identity-constrained-column","status":"publish","type":"post","link":"https:\/\/www.fujiitoshiki.com\/improvesociety\/?p=5339","title":{"rendered":"How to BULK INSERT from text file to the table, which primary key is IDENTITY-constrained column?"},"content":{"rendered":"<div class=\"theContentWrap-ccc\"><p>I&#8217;d like to describe how to BULK INSERT from text file to the table with IDENTITY-constrained primary key. You should insert a column into worksheet for primary key such as &#8216;AUTO_ID&#8217;. <\/p>\n<p><a href=\"\/\/fujiitoshiki.com\/improvesociety\/wp-content\/uploads\/TEXTfile.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/fujiitoshiki.com\/improvesociety\/wp-content\/uploads\/TEXTfile-300x187.png\" alt=\"TEXTfile\" width=\"300\" height=\"187\" class=\"aligncenter size-medium wp-image-5335\" srcset=\"https:\/\/www.fujiitoshiki.com\/improvesociety\/wp-content\/uploads\/TEXTfile-300x187.png 300w, https:\/\/www.fujiitoshiki.com\/improvesociety\/wp-content\/uploads\/TEXTfile.png 1014w\" sizes=\"auto, (max-width: 300px) 85vw, 300px\" \/><\/a><\/p>\n<p>Transact-SQL code is following list. [Table] is table name, FullPath is complete file-path, and FileName is name of text file, respectively. WITH option phrase represents the first row is title. <\/p>\n<pre class=\"lang:tsql decode:true \">\r\nBULK INSERT dbo.[Table] FROM 'FullPath\\FileName.txt' WITH (FIRSTROW = 2);\r\n<\/pre>\n<p><iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"\/\/ws-na.amazon-adsystem.com\/widgets\/q?ServiceVersion=20070822&#038;OneJS=1&#038;Operation=GetAdHtml&#038;MarketPlace=US&#038;source=ss&#038;ref=ss_til&#038;ad_type=product_link&#038;tracking_id=improsocie-20&#038;marketplace=amazon&#038;region=US&#038;placement=0123820227&#038;asins=0123820227&#038;linkId=LXJBROSN54NZGFQG&#038;show_border=true&#038;link_opens_in_new_window=true\"><br \/>\n<\/iframe><iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"\/\/ws-na.amazon-adsystem.com\/widgets\/q?ServiceVersion=20070822&#038;OneJS=1&#038;Operation=GetAdHtml&#038;MarketPlace=US&#038;source=ss&#038;ref=ss_til&#038;ad_type=product_link&#038;tracking_id=improsocie-20&#038;marketplace=amazon&#038;region=US&#038;placement=B00JKMY8KC&#038;asins=B00JKMY8KC&#038;linkId=I4COQKJRN7UCRDBI&#038;show_border=true&#038;link_opens_in_new_window=true\"><br \/>\n<\/iframe><\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>I&#8217;d like to describe how to BULK INSERT from text file to the table with IDENTITY-constrained primary ke &hellip; <a href=\"https:\/\/www.fujiitoshiki.com\/improvesociety\/?p=5339\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;How to BULK INSERT from text file to the table, which primary key is IDENTITY-constrained column?&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":6024,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5339","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.fujiitoshiki.com\/improvesociety\/index.php?rest_route=\/wp\/v2\/posts\/5339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fujiitoshiki.com\/improvesociety\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fujiitoshiki.com\/improvesociety\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fujiitoshiki.com\/improvesociety\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fujiitoshiki.com\/improvesociety\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5339"}],"version-history":[{"count":4,"href":"https:\/\/www.fujiitoshiki.com\/improvesociety\/index.php?rest_route=\/wp\/v2\/posts\/5339\/revisions"}],"predecessor-version":[{"id":5944,"href":"https:\/\/www.fujiitoshiki.com\/improvesociety\/index.php?rest_route=\/wp\/v2\/posts\/5339\/revisions\/5944"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fujiitoshiki.com\/improvesociety\/index.php?rest_route=\/wp\/v2\/media\/6024"}],"wp:attachment":[{"href":"https:\/\/www.fujiitoshiki.com\/improvesociety\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fujiitoshiki.com\/improvesociety\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fujiitoshiki.com\/improvesociety\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}