[dba-SQLServer] dba-SQLServer Digest, Vol 128, Issue 1

David Lewis David at sierranevada.com
Thu Jun 5 13:54:19 CDT 2014



------------------------------

Message: 8
Date: Thu, 5 Jun 2014 13:22:33 -0500
From: Jeff <jeff.developer at gmail.com>
To: Discussion concerning MS SQL Server
<dba-sqlserver at databaseadvisors.com>
Subject: Re: [dba-SQLServer] Appending Data with AutoNumber in SQL
Server
Message-ID: <4355F720-A1AE-4E23-BA52-07028D22C9AE at gmail.com>
Content-Type: text/plain;charset=us-ascii

I NEED to append the Primary Key

Sent from my iPhone

> On Jun 5, 2014, at 11:21 AM, "Doug Murphy" <dw-murphy at cox.net> wrote:
>
> Are you appending the Primary Key or letting SQL server fill? In Access you
> can append a PK value into a table with a query. I am not sure that is the
> case with SQL Server.
>


If you need the key values, and you are certain they do not conflict, you can within sql server do the following:

SET IDENTITY_INSERT tblxyz ON

Your insert statement

SET IDENTITY_INSERT tblxyz OFF

This can be done for only one table in a given session.



________________________________

The contents of this e-mail message and its attachments are covered by the Electronic Communications Privacy Act (18 U.S.C. 2510-2521) and are intended solely for the addressee(s) hereof. If you are not the named recipient, or the employee or agent responsible for delivering the message to the intended recipient, or if this message has been addressed to you in error, you are directed not to read, disclose, reproduce, distribute, disseminate or otherwise use this transmission. If you have received this communication in error, please notify us immediately by return e-mail or by telephone, 530-893-3520, and delete and/or destroy all copies of the message immediately.



More information about the dba-SQLServer mailing list