tags:

views:

31

answers:

1

Hello,

I need to duplicate several tables in a single database. Basically we have an old dot net nuke portal that needs to be split and our host limits us to a single database. So we just want to take the existing tables but copy them with an exact duplicate but different table prefix name (e.g. EEPTL_Users to JBPTL_Users).

I can use 'script to - create' to make the proper table structure but how do I do the proper inserts when I need to specify the primary keys but want the column to be an auto-incrementing identiy?

Is there a tool for doing what I need?

+1  A: 
SET IDENTITY_INSERT [table name] ON

INSERTS

SET IDENTITY_INSERT [table name] OFf
ThatSteveGuy
You've got it backwards. You want to turn IDENTITY_INSERT ON first to insert explicit values, then turn it OFF when you're done.
Joe Stefanelli
I read it as he wants to insert without the identity, and after the copy he wants it to function with identity.
Brett
@Brett: I think you read it correctly. Turning IDENTITY_INSERT ON allows you to specify an explicit value for the identity column. Turing IDENTITY_INSERT OFF forces you to allow the identity column to auto-increment. See [this link](http://msdn.microsoft.com/en-us/library/ms188059.aspx)
Joe Stefanelli
this looks helpful. going to hold out for some miracle solution before accepting though :)
eyston
@eyston - if this isn't exactly what you want, what sort of miracle solution are you looking for?
Brett
@Brett - right-click table, give new name, have it copied for me!
eyston
oops, Joe is correct on the order. My fingers are faster than my brain :)
ThatSteveGuy
can you fix the order so its clear for anyone who gets this by a search?
eyston