From jeff.developer at gmail.com Thu Jun 5 10:55:54 2014 From: jeff.developer at gmail.com (Jeff B) Date: Thu, 5 Jun 2014 10:55:54 -0500 Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server Message-ID: <006201cf80d6$a2d553c0$e87ffb40$@gmail.com> I am going to post this in the Access group as well, as a separate email. I am trying to use MS Access queries to append data from a table in one SQL database into a table in a second SQL database. The first contains live data that needs to be moved to a test database. I have deleted all of the data from the tables in the second database, and have reset the auto number (or identity in SQL) back to 0. However, when I try and use an Access append query, it fails and tells me there are key violations. I thought that be deleting all data and reseeding the identity, I would avoid these problems. Anyone know what I need to do in order to make this work? Jeff Barrows MCP, MCAD, MCSD Racine, WI jeff.developer at gmail.com From rockysmolin at bchacc.com Thu Jun 5 11:00:09 2014 From: rockysmolin at bchacc.com (Rocky Smolin) Date: Thu, 5 Jun 2014 09:00:09 -0700 Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server In-Reply-To: <006201cf80d6$a2d553c0$e87ffb40$@gmail.com> References: <006201cf80d6$a2d553c0$e87ffb40$@gmail.com> Message-ID: <243A50F993CB462E9E8CF84BCD0FB392@HAL9007> Are you trying to append the key from the source table to the target table? Rocky -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jeff B Sent: Thursday, June 05, 2014 8:56 AM To: Dba-SQL Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server I am going to post this in the Access group as well, as a separate email. I am trying to use MS Access queries to append data from a table in one SQL database into a table in a second SQL database. The first contains live data that needs to be moved to a test database. I have deleted all of the data from the tables in the second database, and have reset the auto number (or identity in SQL) back to 0. However, when I try and use an Access append query, it fails and tells me there are key violations. I thought that be deleting all data and reseeding the identity, I would avoid these problems. Anyone know what I need to do in order to make this work? Jeff Barrows MCP, MCAD, MCSD Racine, WI jeff.developer at gmail.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From dw-murphy at cox.net Thu Jun 5 11:21:45 2014 From: dw-murphy at cox.net (Doug Murphy) Date: Thu, 5 Jun 2014 09:21:45 -0700 Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server In-Reply-To: References: Message-ID: <008801cf80da$3e6cfe70$bb46fb50$@cox.net> 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. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jeff B Sent: Thursday, June 05, 2014 8:56 AM To: Dba-SQL Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server I am going to post this in the Access group as well, as a separate email. I am trying to use MS Access queries to append data from a table in one SQL database into a table in a second SQL database. The first contains live data that needs to be moved to a test database. I have deleted all of the data from the tables in the second database, and have reset the auto number (or identity in SQL) back to 0. However, when I try and use an Access append query, it fails and tells me there are key violations. I thought that be deleting all data and reseeding the identity, I would avoid these problems. Anyone know what I need to do in order to make this work? Jeff Barrows MCP, MCAD, MCSD Racine, WI jeff.developer at gmail.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From davidmcafee at gmail.com Thu Jun 5 11:24:53 2014 From: davidmcafee at gmail.com (David McAfee) Date: Thu, 5 Jun 2014 09:24:53 -0700 Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server In-Reply-To: <006201cf80d6$a2d553c0$e87ffb40$@gmail.com> References: <006201cf80d6$a2d553c0$e87ffb40$@gmail.com> Message-ID: Are you inserting the PK too? If you are bring the PK from table 1 into table 2, make sure the PK for Table 2 isn't an auto-incrementing Identity or If you aren't bringing the PK over, make sure that the PK in table 2 IS an IDENTITY(1,1) especially if table 2's PK column is set to not allow nulls On Thu, Jun 5, 2014 at 8:55 AM, Jeff B wrote: > I am going to post this in the Access group as well, as a separate email. > > > > I am trying to use MS Access queries to append data from a table in one SQL > database into a table in a second SQL database. The first contains live > data that needs to be moved to a test database. I have deleted all of the > data from the tables in the second database, and have reset the auto number > (or identity in SQL) back to 0. However, when I try and use an Access > append query, it fails and tells me there are key violations. I thought > that be deleting all data and reseeding the identity, I would avoid these > problems. Anyone know what I need to do in order to make this work? > > > > Jeff Barrows > > MCP, MCAD, MCSD > > > > Racine, WI > > jeff.developer at gmail.com > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From fhtapia at gmail.com Thu Jun 5 11:39:34 2014 From: fhtapia at gmail.com (Francisco Tapia) Date: Thu, 5 Jun 2014 09:39:34 -0700 Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server In-Reply-To: <006201cf80d6$a2d553c0$e87ffb40$@gmail.com> References: <006201cf80d6$a2d553c0$e87ffb40$@gmail.com> Message-ID: is there any reason you don't simply just restore the backup form the live database as a "test" database to your target server? Depending on how your front end app works, (ie, you have an app uid ) then you'll need to migrate the user to the test server too. if your test and live databases live on the same server then you can skip the migration of users. -Francisco On Thu, Jun 5, 2014 at 8:55 AM, Jeff B wrote: > I am going to post this in the Access group as well, as a separate email. > > > > I am trying to use MS Access queries to append data from a table in one SQL > database into a table in a second SQL database. The first contains live > data that needs to be moved to a test database. I have deleted all of the > data from the tables in the second database, and have reset the auto number > (or identity in SQL) back to 0. However, when I try and use an Access > append query, it fails and tells me there are key violations. I thought > that be deleting all data and reseeding the identity, I would avoid these > problems. Anyone know what I need to do in order to make this work? > > > > Jeff Barrows > > MCP, MCAD, MCSD > > > > Racine, WI > > jeff.developer at gmail.com > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From jeff.developer at gmail.com Thu Jun 5 13:22:33 2014 From: jeff.developer at gmail.com (Jeff) Date: Thu, 5 Jun 2014 13:22:33 -0500 Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server In-Reply-To: <008801cf80da$3e6cfe70$bb46fb50$@cox.net> References: <008801cf80da$3e6cfe70$bb46fb50$@cox.net> Message-ID: <4355F720-A1AE-4E23-BA52-07028D22C9AE@gmail.com> I NEED to append the Primary Key Sent from my iPhone > On Jun 5, 2014, at 11:21 AM, "Doug Murphy" 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. > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jeff B > Sent: Thursday, June 05, 2014 8:56 AM > To: Dba-SQL > Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server > > I am going to post this in the Access group as well, as a separate email. > > > > I am trying to use MS Access queries to append data from a table in one SQL > database into a table in a second SQL database. The first contains live > data that needs to be moved to a test database. I have deleted all of the > data from the tables in the second database, and have reset the auto number > (or identity in SQL) back to 0. However, when I try and use an Access > append query, it fails and tells me there are key violations. I thought > that be deleting all data and reseeding the identity, I would avoid these > problems. Anyone know what I need to do in order to make this work? > > > > Jeff Barrows > > MCP, MCAD, MCSD > > > > Racine, WI > > jeff.developer at gmail.com > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From jeff.developer at gmail.com Thu Jun 5 13:26:28 2014 From: jeff.developer at gmail.com (Jeff) Date: Thu, 5 Jun 2014 13:26:28 -0500 Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server In-Reply-To: References: <006201cf80d6$a2d553c0$e87ffb40$@gmail.com> Message-ID: <14D40D57-BE25-4417-8B07-43EB0DDD7468@gmail.com> Biggest issue is that some of the tables have been changed on the test database and I don't want to have to recreate all the changes if I don't have to. Sent from my iPhone > On Jun 5, 2014, at 11:39 AM, Francisco Tapia wrote: > > is there any reason you don't simply just restore the backup form the live > database as a "test" database to your target server? Depending on how your > front end app works, (ie, you have an app uid ) then you'll need to migrate > the user to the test server too. > > if your test and live databases live on the same server then you can skip > the migration of users. > > -Francisco > > > > >> On Thu, Jun 5, 2014 at 8:55 AM, Jeff B wrote: >> >> I am going to post this in the Access group as well, as a separate email. >> >> >> >> I am trying to use MS Access queries to append data from a table in one SQL >> database into a table in a second SQL database. The first contains live >> data that needs to be moved to a test database. I have deleted all of the >> data from the tables in the second database, and have reset the auto number >> (or identity in SQL) back to 0. However, when I try and use an Access >> append query, it fails and tells me there are key violations. I thought >> that be deleting all data and reseeding the identity, I would avoid these >> problems. Anyone know what I need to do in order to make this work? >> >> >> >> Jeff Barrows >> >> MCP, MCAD, MCSD >> >> >> >> Racine, WI >> >> jeff.developer at gmail.com >> >> >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From rockysmolin at bchacc.com Thu Jun 5 13:28:01 2014 From: rockysmolin at bchacc.com (Rocky Smolin) Date: Thu, 5 Jun 2014 11:28:01 -0700 Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server In-Reply-To: <4355F720-A1AE-4E23-BA52-07028D22C9AE@gmail.com> References: <008801cf80da$3e6cfe70$bb46fb50$@cox.net> <4355F720-A1AE-4E23-BA52-07028D22C9AE@gmail.com> Message-ID: I don't know SQL that well but when I had to do this in an mdb, I changed the Autonumber to a long integer then changed it back later. The other way is - assuming the primary key is a foreign key in some child table(s) and you need that one to many relationship, is to write the new PK for the FK field in the child tables - PITA I know since you probably can't do that with queries and it needs to be coded. Hth Rocky -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jeff Sent: Thursday, June 05, 2014 11:23 AM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Appending Data with AutoNumber in SQL Server I NEED to append the Primary Key Sent from my iPhone > On Jun 5, 2014, at 11:21 AM, "Doug Murphy" 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. > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jeff > B > Sent: Thursday, June 05, 2014 8:56 AM > To: Dba-SQL > Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server > > I am going to post this in the Access group as well, as a separate email. > > > > I am trying to use MS Access queries to append data from a table in > one SQL database into a table in a second SQL database. The first > contains live data that needs to be moved to a test database. I have > deleted all of the data from the tables in the second database, and > have reset the auto number (or identity in SQL) back to 0. However, > when I try and use an Access append query, it fails and tells me there > are key violations. I thought that be deleting all data and reseeding > the identity, I would avoid these problems. Anyone know what I need to do in order to make this work? > > > > Jeff Barrows > > MCP, MCAD, MCSD > > > > Racine, WI > > jeff.developer at gmail.com > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From df.waters at outlook.com Thu Jun 5 13:30:58 2014 From: df.waters at outlook.com (Dan Waters) Date: Thu, 5 Jun 2014 13:30:58 -0500 Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server In-Reply-To: <4355F720-A1AE-4E23-BA52-07028D22C9AE@gmail.com> References: <008801cf80da$3e6cfe70$bb46fb50$@cox.net> <4355F720-A1AE-4E23-BA52-07028D22C9AE@gmail.com> Message-ID: Hi Jeff, What I've done in Access is: Create a blank new table same as original. In the new table remove primary key and autonumber functionality from the PK field. Copy the data. Now reset the PK field primary key and autonumber functionality. This does work in Access IF the PK numbers don't have any gaps. I would try this using an Access file with tables linked to the SQL Server tables (I haven't done this with SQL Server but I think it's worth a try). Good Luck! Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jeff Sent: Thursday, June 05, 2014 13:23 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Appending Data with AutoNumber in SQL Server I NEED to append the Primary Key Sent from my iPhone > On Jun 5, 2014, at 11:21 AM, "Doug Murphy" 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. > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jeff > B > Sent: Thursday, June 05, 2014 8:56 AM > To: Dba-SQL > Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server > > I am going to post this in the Access group as well, as a separate email. > > > > I am trying to use MS Access queries to append data from a table in > one SQL database into a table in a second SQL database. The first > contains live data that needs to be moved to a test database. I have > deleted all of the data from the tables in the second database, and > have reset the auto number (or identity in SQL) back to 0. However, > when I try and use an Access append query, it fails and tells me there > are key violations. I thought that be deleting all data and reseeding > the identity, I would avoid these problems. Anyone know what I need to do in order to make this work? > > > > Jeff Barrows > > MCP, MCAD, MCSD > > > > Racine, WI > > jeff.developer at gmail.com > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From David at sierranevada.com Thu Jun 5 13:54:19 2014 From: David at sierranevada.com (David Lewis) Date: Thu, 5 Jun 2014 18:54:19 +0000 Subject: [dba-SQLServer] dba-SQLServer Digest, Vol 128, Issue 1 In-Reply-To: References: Message-ID: <39f835dddc004fbba46ffa804e90bb16@cic-ex13mb-03.sierranevada.corp> ------------------------------ Message: 8 Date: Thu, 5 Jun 2014 13:22:33 -0500 From: Jeff To: Discussion concerning MS SQL Server 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" 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. From accessd at shaw.ca Thu Jun 5 14:16:00 2014 From: accessd at shaw.ca (Jim Lawrence) Date: Thu, 5 Jun 2014 13:16:00 -0600 (MDT) Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server In-Reply-To: <006201cf80d6$a2d553c0$e87ffb40$@gmail.com> Message-ID: <1158885851.3005555.1401995760105.JavaMail.root@cds018> Hi Jeff: Have all the keys fields been removed from the destination table? That is the best way to do it even if the receiving key fields are not automated. If a destination table is full of indexes, the appending process will be excruciatingly slow as the receiving table has to re-index after every new record. MS SQL 101. Jim ----- Original Message ----- From: "Jeff B" To: "Dba-SQL" Sent: Thursday, June 5, 2014 8:55:54 AM Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server I am going to post this in the Access group as well, as a separate email. I am trying to use MS Access queries to append data from a table in one SQL database into a table in a second SQL database. The first contains live data that needs to be moved to a test database. I have deleted all of the data from the tables in the second database, and have reset the auto number (or identity in SQL) back to 0. However, when I try and use an Access append query, it fails and tells me there are key violations. I thought that be deleting all data and reseeding the identity, I would avoid these problems. Anyone know what I need to do in order to make this work? Jeff Barrows MCP, MCAD, MCSD Racine, WI jeff.developer at gmail.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From accessd at shaw.ca Thu Jun 5 14:20:15 2014 From: accessd at shaw.ca (Jim Lawrence) Date: Thu, 5 Jun 2014 13:20:15 -0600 (MDT) Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server In-Reply-To: <4355F720-A1AE-4E23-BA52-07028D22C9AE@gmail.com> Message-ID: <1777666599.3008968.1401996015538.JavaMail.root@cds018> Hi Jeff: Then delete key first and then add the key back after the data has been inserted. There is no other way. Jim ----- Original Message ----- From: "Jeff" To: "Discussion concerning MS SQL Server" Sent: Thursday, June 5, 2014 11:22:33 AM Subject: Re: [dba-SQLServer] Appending Data with AutoNumber in SQL Server I NEED to append the Primary Key Sent from my iPhone > On Jun 5, 2014, at 11:21 AM, "Doug Murphy" 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. > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jeff B > Sent: Thursday, June 05, 2014 8:56 AM > To: Dba-SQL > Subject: [dba-SQLServer] Appending Data with AutoNumber in SQL Server > > I am going to post this in the Access group as well, as a separate email. > > > > I am trying to use MS Access queries to append data from a table in one SQL > database into a table in a second SQL database. The first contains live > data that needs to be moved to a test database. I have deleted all of the > data from the tables in the second database, and have reset the auto number > (or identity in SQL) back to 0. However, when I try and use an Access > append query, it fails and tells me there are key violations. I thought > that be deleting all data and reseeding the identity, I would avoid these > problems. Anyone know what I need to do in order to make this work? > > > > Jeff Barrows > > MCP, MCAD, MCSD > > > > Racine, WI > > jeff.developer at gmail.com > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com