Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Identity insertion and updation Expand / Collapse
Author
Message
Posted Tuesday, January 8, 2008 12:13 PM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Thursday, July 24, 2014 4:49 PM
Points: 4,065, Visits: 5,277
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
Post #440223
Posted Tuesday, January 8, 2008 7:02 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 8:36 AM
Points: 36,777, Visits: 31,232
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 ;)


--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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #440377
Posted Tuesday, January 8, 2008 7:05 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 8:36 AM
Points: 36,777, Visits: 31,232
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???


--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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #440378
Posted Sunday, January 24, 2010 11:48 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, March 10, 2014 9:05 AM
Points: 421, Visits: 363
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/
Post #852848
Posted Sunday, January 24, 2010 11:50 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, March 10, 2014 9:05 AM
Points: 421, Visits: 363
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/
Post #852850
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse