Identity Column Problem in MS SQL Server

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2006
Posts: 38
Reputation: asifjavaid is an unknown quantity at this point 
Solved Threads: 0
asifjavaid asifjavaid is offline Offline
Light Poster

Identity Column Problem in MS SQL Server

 
0
  #1
Oct 18th, 2006
Hi all,
God Bless U,
i am facing a problem in SQL Server. I am have a table given below..
------------------------------------------------
Table name is "A"
------------------------------------------------
1 Michle Administrator
2 John Consumer Finance Officer
3 Jackson Employer
4 Goeffery Empl0yer
------------------------------------------------
Here the identity column is the first one. Now if i delete the 2nd row the this table becomes like that
------------------------------------------------
Table name is "A"
------------------------------------------------
1 Michle Administrator
3 Jackson Employer
4 Goeffery Empl0yer
------------------------------------------------
Now i have an another table "B" having same structure (3 columns and first column is the identity column). Now if i move the all the data from table "A" to table "B" then the original seqeunce is distrubed the table "B" contains the data like this.

------------------------------------------------
Table name is "B"
------------------------------------------------
1 Michle Administrator
2 Jackson Employer
3 Goeffery Empl0yer
------------------------------------------------

but i need that what ever the first column is identity column but sequence of numbering must be same as the numbering in the table "A" to preserve the relationships.... like that...

------------------------------------------------
Table name is "B"
------------------------------------------------
1 Michle Administrator
3 Jackson Employer
4 Goeffery Empl0yer
------------------------------------------------

waiting for ur responce. i will very thankful to you by giving me effecient and excellent solution.
Thanks....
God Bless u By all means.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 44
Reputation: MCP is an unknown quantity at this point 
Solved Threads: 3
MCP MCP is offline Offline
Light Poster

Re: Identity Column Problem in MS SQL Server

 
0
  #2
Oct 19th, 2006
How are you moving the data? Through SQL statements? Through the EM Import Wizard?

Anyhow, the answer is enabling "identity insert" in your target table B. This option can only be active for one table at any given moment, and is usually turned on, data copied, then turned off again.

I'd argue though that the id field in table B shouldn't be an identity at all. You can still make it a primary key, but it's not really an identity field.

Without knowing more about your DB's design, it's hard to say though.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 38
Reputation: asifjavaid is an unknown quantity at this point 
Solved Threads: 0
asifjavaid asifjavaid is offline Offline
Light Poster

Re: Identity Column Problem in MS SQL Server2

 
0
  #3
Oct 19th, 2006
Originally Posted by asifjavaid View Post
Hi all,
God Bless U,
i am facing a problem in SQL Server. I am have a table given below..
------------------------------------------------
Table name is "A"
------------------------------------------------
1 Michle Administrator
2 John Consumer Finance Officer
3 Jackson Employer
4 Goeffery Empl0yer
------------------------------------------------
Here the identity column is the first one. Now if i delete the 2nd row the this table becomes like that
------------------------------------------------
Table name is "A"
------------------------------------------------
1 Michle Administrator
3 Jackson Employer
4 Goeffery Empl0yer
------------------------------------------------
Now i have an another table "B" having same structure (3 columns and first column is the identity column). Now if i move the all the data from table "A" to table "B" then the original seqeunce is distrubed the table "B" contains the data like this.

------------------------------------------------
Table name is "B"
------------------------------------------------
1 Michle Administrator
2 Jackson Employer
3 Goeffery Empl0yer
------------------------------------------------

but i need that what ever the first column is identity column but sequence of numbering must be same as the numbering in the table "A" to preserve the relationships.... like that...

------------------------------------------------
Table name is "B"
------------------------------------------------
1 Michle Administrator
3 Jackson Employer
4 Goeffery Empl0yer
------------------------------------------------

waiting for ur responce. i will very thankful to you by giving me effecient and excellent solution.
Thanks....
God Bless u By all means.
***********************************************************
***********************************************************
***********************************************************
date :- Thursday, October 19, 2006
Hi all dear
Thank you so much in responce to much problem.....

Dear friend,
in responce to reply, i am saying that your solution is very good for inserting one statement but i am trying to move data from table "A" to table "B" using Bulk copying. My dear now tell me what will be the solution in case of Bulk copy....?????

I hope to get an excellent responce from you side....
very very thanks.
God Bless u By all means
Asif Javaid
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC