SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Identity insertion and updation


Identity insertion and updation

Author
Message
Greg Charles
Greg Charles
SSCertifiable
SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)

Group: General Forum Members
Points: 5479 Visits: 5927
I'm a little confused. Early in the thread it sounded like you want to remove the identity property and retain the data, but your last post sounds like you are okay with dropping the columns with identity property from the tables.

Are you ultimately wanting to have 500 tables with no identity columns?

Greg

Greg
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)

Group: General Forum Members
Points: 85533 Visits: 41081
balaji_rcs (12/24/2007)
Hi,

Thanks for your reply. I want to remove the identity properties in the table totally. i.e I want to remove the identity while update also.


Yeah, uh-huh... what are you going to use to replace the auto-numbering property of the IDENTITY property? Sequence table? Better post that code so we can check it or you'll end up with a bazillion deadlocks per day. SELECT MAX()? Again, better post that code so we can make sure that you won't end up with dupe ID's on a high usage system.

And, then, you might as well convert all of your code to bloody cursors because you're gonna have a hell of a time inserting more than one row at a time no matter which of those two methods you use. If you have a third method not offered above, please post it... I want to see what type of knife you're falling on Wink

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)

Group: General Forum Members
Points: 85533 Visits: 41081
Kishore.P (1/8/2008)
use sp_msforeachtable to drop the identity column in all tables.


Yup... easy to do if no foreign keys... of course, if these IDENTITY columns are being used as the PK for tables, your whole database becomes a useless piece of slag.

C'mon folks! Doesn't anyone else see a problem with this request??? Blink

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
G.R.Prithiviraj Kulasingham
G.R.Prithiviraj Kulasingham
Mr or Mrs. 500
Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)

Group: General Forum Members
Points: 565 Visits: 367
Removing identity property is something I have seen many people doing for some reason.
Most of the time, they perform an additional query to get the next value and then pass it. This method creates additional locks and will not work perfectly in a multi user environment.

I believe identity is one of the good things SQL Server has.
Having said that, there is another way of moving them. It will work better if you do not have foreign keys defined against this table and this table is large.
As of now, it will work only in enterprise edition of SQL Server 2005, but I believe it will work in some additional editions of SQL Server 2008

1. Create another table with the same structure except the identity property.
2. Switch the data from old table to new table
3. Drop the old table (which has the identity property)
4. Rename the new table with proper name.

In case you have soem foreign keys you need to drop the foreign keys and re-create them.
I heard that SQL Server mobile edition has a command where you can simply turn off the identity property, but it is not yet available on other editions.

Cheers,
Prithiviraj Kulasingham

http://preethiviraj.blogspot.com/
G.R.Prithiviraj Kulasingham
G.R.Prithiviraj Kulasingham
Mr or Mrs. 500
Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)Mr or Mrs. 500 (565 reputation)

Group: General Forum Members
Points: 565 Visits: 367
Oops I just realized that this is quite old thread. I am not sure why it suddenly came into my screen.

Cheers,
Prithiviraj Kulasingham

http://preethiviraj.blogspot.com/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search