{"id":814,"date":"2009-03-31T07:15:04","date_gmt":"2009-03-30T22:15:04","guid":{"rendered":"http:\/\/gigasmegas.com\/?p=814"},"modified":"2009-04-01T12:14:08","modified_gmt":"2009-04-01T03:14:08","slug":"sql-server-2008-set-identity_insert%e3%81%a7%e4%bb%bb%e6%84%8f%e3%81%aeid%e5%80%a4%e3%82%92%e6%8c%bf%e5%85%a5%e3%81%a7%e3%81%8d%e3%82%8b","status":"publish","type":"post","link":"http:\/\/gigasmegas.com\/?p=814","title":{"rendered":"SQL SERVER 2008 SET IDENTITY_INSERT\u3067\u4efb\u610f\u306eID\u5024\u3092\u633f\u5165\u3067\u304d\u308b"},"content":{"rendered":"<p><a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/rokuz.com\/?p=814');\"  href=\"http:\/\/rokuz.com\/?p=814\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/rokuz.com\/wp-content\/uploads\/2009\/03\/snag-0077-400x249.png\" alt=\"SET IDENTITY_INSERT\u3067ID\u5024\u3092\u633f\u5165\" title=\"SET IDENTITY_INSERT\u3067ID\u5024\u3092\u633f\u5165\" width=\"400\" height=\"249\" class=\"alignnone size-medium wp-image-821\" srcset=\"http:\/\/gigasmegas.com\/wp-content\/uploads\/2009\/03\/snag-0077-400x249.png 400w, http:\/\/gigasmegas.com\/wp-content\/uploads\/2009\/03\/snag-0077.png 493w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<address>photo by <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.flickr.com\/photos\/ballyooo\/');\"  href=\"http:\/\/www.flickr.com\/photos\/ballyooo\/\">BaLLYoOo<\/a><\/address>\n<p>SQL SERVER 2008 \u306e\u30c6\u30fc\u30d6\u30eb\u306bIDENTITY\u5217\u3092\u8ffd\u52a0\u3057\u3066\u3001\u30c7\u30fc\u30bf\u633f\u5165\u6642\u306b\u30aa\u30fc\u30c8\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3067ID\u5024\u3092\u81ea\u52d5\u5897\u52a0\u3055\u305b\u308b\u3053\u3068\u306f\u3088\u304f\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u4e00\u65e6\u3001IDENTITY\u5217\u3092\u8a2d\u5b9a\u3057\u3066\u3042\u308b\u30c6\u30fc\u30d6\u30eb\u306bID\u5024\u3092\u3042\u3089\u304b\u3058\u3081\u660e\u793a\u3057\u3066\u633f\u5165\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001IDENTITY\u5217\u304c\u8a2d\u5b9a\u3057\u3066\u3042\u308b\u306e\u3067\u3001\u8ffd\u52a0\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u3053\u308c\u306f\u3001\u3053\u308c\u3067\u6b63\u3057\u3044\u4ed5\u69d8\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u3059\u304c\u3001\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\u3057\u305f\u76f4\u5f8c\u306b\u3042\u3089\u304b\u3058\u3081\u30c7\u30fc\u30bf\u3092\u3044\u304f\u3064\u304b\u633f\u5165\u3057\u3066\u304a\u304d\u305f\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u3093\u306a\u6642\u3001\u3069\u3046\u3059\u308c\u3070\u3044\u3044\u306e\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<p><!--more--><\/p>\n<h4>SET IDENTITY_INSERT\u3092&#8221;ON&#8221;\u3001&#8221;OFF&#8221;\u3059\u308b<\/h4>\n<p>\u3053\u306e\u3088\u3046\u306a\u6642\u306e\u305f\u3081\u306b\u3001IDENTITY\u5217\u306b\u5024\u3092\u633f\u5165\u3067\u304d\u308b\u6a5f\u80fd\u304c\u5099\u308f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h5>\u69cb\u6587<\/h5>\n<p>SET IDENTITY_INSERT [ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d. [ schema_name ] . ] \u30c6\u30fc\u30d6\u30eb\u540d { ON | OFF }<\/p>\n<h5>\u5f15\u6570<\/h5>\n<dt>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d<\/dt>\n<dd>\u6307\u5b9a\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u540d\u524d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/dd>\n<dt>schema_name<\/dt>\n<dd>\u30c6\u30fc\u30d6\u30eb\u304c\u6240\u5c5e\u3059\u308b\u30b9\u30ad\u30fc\u30de\u306e\u540d\u524d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/dd>\n<dt>\u30c6\u30fc\u30d6\u30eb\u540d<\/dt>\n<dd>ID \u5217\u304c\u3042\u308b\u30c6\u30fc\u30d6\u30eb\u306e\u540d\u524d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/dd>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nDim objConn = New SqlConnection(&quot;Data Source=&quot; DataSource &quot;;Initial Catalog=&quot;InitialCatalog  &quot;;Integrated Security=&quot; My.Settings.DBIntegratedSecurity)\r\nDim objCmd = New SqlCommand\r\nDim SQLStr As String\r\n\r\nSQLStr = &quot;SET IDENTITY_INSERT combo ON&quot;\r\nobjCmd = New SqlCommand(SQLStr, objConn)\r\nobjCmd.CommandType = CommandType.Text\r\nobjCmd.ExecuteNonQuery()\r\n\r\n'\u3053\u3053\u3067INSERT\u51e6\u7406\u3092\u3059\u308b\r\n\r\n'INSERT\u51e6\u7406\u304c\u7d42\u308f\u3063\u305f\u3089\r\n'SET IDENTITY_INSERT\u3092\u201dOFF\u201d\u306b\u623b\u3059\r\nSQLStr = &quot;SET IDENTITY_INSERT combo OFF&quot;\r\nobjCmd = New SqlCommand(SQLStr, objConn)\r\nobjCmd.CommandType = CommandType.Text\r\nobjCmd.ExecuteNonQuery()\r\n<\/pre>\n<h5>\u5236\u9650 \uff70 SET IDENTITY_INSERT<\/h5>\n<p>IDENTITY_INSERT \u30d7\u30ed\u30d1\u30c6\u30a3\u3092 ON \u306b\u8a2d\u5b9a\u3067\u304d\u308b\u306e\u306f\u3001\u30bb\u30c3\u30b7\u30e7\u30f3\u5185\u306e 1 \u3064\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u307f\u3002<\/p>\n<p>1 \u3064\u306e\u30c6\u30fc\u30d6\u30eb\u3067\u65e2\u306b\u3053\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u304c ON \u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u30a8\u30e9\u30fc\u304c\u8fd4\u3055\u308c\u308b\u3002<\/p>\n<h5>ID\u5024\u306e\u4ed5\u69d8<\/h5>\n<p>\u633f\u5165\u3059\u308b\u5024\u304c\u30c6\u30fc\u30d6\u30eb\u306e\u73fe\u5728\u306e ID \u5024\u3088\u308a\u3082\u5927\u304d\u3044\u5834\u5408\u3001\u65b0\u3057\u304f\u633f\u5165\u3055\u308c\u305f\u5024\u304c\u73fe\u5728\u306e ID \u5024\u3068\u3057\u3066\u81ea\u52d5\u7684\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff1a\u305d\u308c\u307e\u3067ID\u5024\u306eMAX\u304c&#8221;10&#8243;\u3067\u3001\u305d\u3053\u306bID\u5024&#8221;100&#8243;\u3092\u633f\u5165\u3059\u308b\u3068\u3001\u6b21\u306eID\u5024\u306f&#8221;11&#8243;\u3067\u306f\u306a\u304f\u3001&#8221;101&#8243;\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h5>\u305d\u306e\u4ed6<\/h5>\n<p>SET IDENTITY_INSERT\u3092\u4f7f\u7528\u3059\u308c\u3070\u3001\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\u5f8c\u306e\u30c7\u30fc\u30bf\u306e\u4e8b\u524d\u633f\u5165\u3001DELETE\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u306b\u3088\u3063\u3066\u767a\u751f\u3059\u308b\u3001ID\u5024\u306e\u30ae\u30e3\u30c3\u30d7\u8abf\u6574\u306a\u3069\u3001\u3044\u308d\u3044\u308d\u4f7f\u7528\u3067\u304d\u305d\u3046\u306a\u5834\u9762\u304c\u3042\u308a\u305d\u3046\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>photo by BaLLYoOo SQL SERVER 2008 \u306e\u30c6\u30fc\u30d6\u30eb\u306bIDENTITY\u5217\u3092\u8ffd\u52a0\u3057\u3066\u3001\u30c7\u30fc\u30bf\u633f\u5165\u6642\u306b\u30aa\u30fc\u30c8\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3067ID\u5024\u3092\u81ea\u52d5\u5897\u52a0\u3055\u305b\u308b\u3053\u3068\u306f\u3088\u304f\u3042\u308a\u307e\u3059\u3002 \u3057\u304b\u3057\u3001\u4e00\u65e6\u3001IDENTITY [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31,32],"tags":[272,309,296,250,157,301],"class_list":["post-814","post","type-post","status-publish","format-standard","hentry","category-sqlserver","category-database","tag-272","tag-id","tag-identity","tag-sql","tag-157","tag-301"],"_links":{"self":[{"href":"http:\/\/gigasmegas.com\/index.php?rest_route=\/wp\/v2\/posts\/814","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/gigasmegas.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/gigasmegas.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/gigasmegas.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/gigasmegas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=814"}],"version-history":[{"count":13,"href":"http:\/\/gigasmegas.com\/index.php?rest_route=\/wp\/v2\/posts\/814\/revisions"}],"predecessor-version":[{"id":855,"href":"http:\/\/gigasmegas.com\/index.php?rest_route=\/wp\/v2\/posts\/814\/revisions\/855"}],"wp:attachment":[{"href":"http:\/\/gigasmegas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/gigasmegas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=814"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/gigasmegas.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}