<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Attinder Pal Singh's Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/attinder/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/attinder/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 04:10:42 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Export Data Utility Problem With Identity Column</title>
      <link>https://docs.microsoft.com/archive/blogs/attinder/export-data-utility-problem-with-identity-column</link>
      <pubDate>Wed, 21 Dec 2016 17:10:03 GMT</pubDate>
      <dc:creator><![CDATA[Attinder Pal]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/attinder/?p=25</guid>
      <description><![CDATA[Problem Statement

Export Data utility not working appropriately to export the tables containing...]]></description>
      <content:encoded><![CDATA[<strong><u>Problem Statement</u></strong>

Export Data utility not working appropriately to export the tables containing <strong>identity</strong> column?

Data could be exported but the identity property is showing as disabled on the destination server?

The issue is seen even after enabling the <strong>Enable Identity Insert?</strong>

If you are experiencing above symptoms, I would like to inform that this is a by-design behavior.

<strong><u>Repro Steps:</u></strong>
<ul>
 	<li>Exporting the data using <strong>Export Data</strong> utility:
<ul></ul>
</li>
</ul>
<strong>              </strong><img width="500" height="373" class="alignnone wp-image-65" alt="1" src="https://msdnshared.blob.core.windows.net/media/2016/12/140.png" />

&nbsp;
<ul>
 	<li>Select the <strong>Enable Identity Insert</strong> property and click <strong>OK</strong>.</li>
</ul>
<strong>              </strong><img width="500" height="436" class="alignnone wp-image-45" alt="exportutility_2" src="https://msdnshared.blob.core.windows.net/media/2016/12/exportutility_2.png" />

<strong>              </strong>Complete data will be exported fine but the problem is as explained in below screenshots:

&nbsp;
<ul>
 	<li><b><strong>Source Server – </strong></b>Identity property is enabled.</li>
</ul>
<strong>              <img width="500" height="255" class="alignnone wp-image-55" alt="sqlserverexport_identity3" src="https://msdnshared.blob.core.windows.net/media/2016/12/sqlserverexport_identity3.png" /></strong>

&nbsp;
<ul>
 	<li><b><strong>Destination Server </strong></b>– Identity value is disabled. However, the data is present in the table.</li>
</ul>
<strong></strong>               <img width="500" height="294" class="alignnone wp-image-36" alt="export_4" src="https://msdnshared.blob.core.windows.net/media/2016/12/export_4.png" />

&nbsp;

<span style="text-decoration: underline">The <strong>reason</strong> for the difference:</span>

When you create a table using export wizard it does not create the table with Identity attribute. Check the create table SQL statement under

Edit mappings --&gt; Column mappings --&gt; Edit SQL. This SQL does not contain the Identity in the table creation script.

<strong>                     <img width="450" height="347" class="alignnone wp-image-46" alt="identity_5" src="https://msdnshared.blob.core.windows.net/media/2016/12/identity_5.png" /></strong>

<strong> </strong>

<span style="text-decoration: underline"><strong>Approaches to fix this problem:</strong></span>

<strong>Approach 1:</strong> Check the create table SQL statement under Edit mappings --&gt; Column mappings --&gt; Edit SQL. This SQL does not contain the Identity in the table creation script. You could add IDENTITY in the create table script as shown in figure below: <strong>                     </strong><strong>                     </strong><strong>                      <img width="809" height="294" class="alignnone wp-image-67 size-full" alt="6" src="https://msdnshared.blob.core.windows.net/media/2016/12/612.png" /></strong>

&nbsp;

<strong>Approach 2:</strong> Generate the table script
<p style="text-align: left">         a. Right click on database --&gt; Tasks --&gt; Generate Scripts --&gt; Select specific database objects --</p>
<p style="text-align: left">         -&gt; Select the tables you want to script out --&gt; Check the properties in Advanced and enable/disable the property, if required.</p>
             Refer article - <a href="https://technet.microsoft.com/en-us/library/ms178078(v=sql.105).aspx">https://technet.microsoft.com/en-us/library/ms178078(v=sql.105).aspx</a>

<strong>         </strong>b. Execute this script to create the objects on the destination server.

<strong>Approach 3:</strong> Use <strong>Import Data </strong>utility on Destination server to import the data. While selecting the options, please check the <strong>Enable Identity </strong><strong>Insert </strong>under<strong> Edit Mappings</strong> option (refer below screenshot).

<strong>                    </strong><img width="500" height="282" class="alignnone wp-image-35" alt="7" src="https://msdnshared.blob.core.windows.net/media/2016/12/712.png" />

<strong>                    </strong>Validate the column properties to ensure Identity is enabled.

&nbsp;

<span style="text-decoration: underline"><strong>Related Articles:</strong></span>

SET IDENTITY_INSERT - <a href="https://msdn.microsoft.com/en-us/library/ms188059.aspx">https://msdn.microsoft.com/en-us/library/ms188059.aspx</a>

Keep Identity Values When Bulk Importing Data (SQL Server) - <a href="https://msdn.microsoft.com/en-us/library/ms186335.aspx">https://msdn.microsoft.com/en-us/library/ms186335.aspx</a>

&nbsp;

Please share your feedback, questions and/or suggestions.

Thanks,

Attinder Pal Singh | CSS – Microsoft
<blockquote><em>Disclaimer: All posts are provided AS IS with no warranties and confer no rights. Additionally, views expressed here are my own and not those of my employer, Microsoft.</em></blockquote>]]></content:encoded>
    </item>
  </channel>
</rss>