Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 579
  • Last Modified:

Copy into table with identity insert

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
lrbrister
Asked:
lrbrister
  • 3
2 Solutions
 
HainKurtSr. System AnalystCommented:
SET IDENTITY INSERT myTable ON;
insert into myTable values (...);
SET IDENTITY INSERT myTable OFF;
0
 
HainKurtSr. System AnalystCommented:
oops, _

SET IDENTITY_INSERT myTable ON;
insert into myTable values (...);
SET IDENTITY_INSERT myTable OFF;
0
 
HainKurtSr. System AnalystCommented:
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
 
lrbristerAuthor Commented:
Perfect...thanks
0
 
devlab2012Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now