Solved

Copy into table with identity insert

Posted on 2011-02-15
5
541 Views
Last Modified: 2012-05-11
How can I run the code below with identity insert  when I copy from the...BU to live?

delete from proc_cfa.dbo.P_AvailableForSale

Select * into proc_cfa.dbo.P_AvailableForSale
from proc_cfa.dbo.P_AvailableForSaleBU
 
0
Comment
Question by:lrbrister
  • 3
5 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 34897868
SET IDENTITY INSERT myTable ON;
insert into myTable values (...);
SET IDENTITY INSERT myTable OFF;
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 34897880
oops, _

SET IDENTITY_INSERT myTable ON;
insert into myTable values (...);
SET IDENTITY_INSERT myTable OFF;
0
 
LVL 51

Assisted Solution

by:HainKurt
HainKurt earned 500 total points
ID: 34897894
you can turn it on only for one table at a time:

http://msdn.microsoft.com/en-us/library/aa259221(v=sql.80).aspx
0
 

Author Closing Comment

by:lrbrister
ID: 34897909
Perfect...thanks
0
 
LVL 13

Expert Comment

by:devlab2012
ID: 34897932
Here is the set of queries:

delete from proc_cfa.dbo.P_AvailableForSale


SET IDENTITY_INSERT proc_cfa.dbo.P_AvailableForSale ON

Select * into proc_cfa.dbo.P_AvailableForSale
from proc_cfa.dbo.P_AvailableForSaleBU

SET IDENTITY_INSERT proc_cfa.dbo.P_AvailableForSaleOFF

Note that there is "_" in indetity_insert.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question