identity-column

Sql Server Legacy Database To Clustered index or not

Hi All, We have a legacy database which is a sql server db (2005, and 2008). All of the primary keys in the tables are UniqueIdentifiers. The tables currently have no clustered index created on them and we are running into performance issues on tables with only 750k records. This is the first database i've worked on with unique id...

SQL table function or means to tell if identity column has been used?

I was curious if there is a way to tell if an IDENTITY column has ever been incremented if there is no data within the table. (i.e. data item was inserted, then deleted) ...

Benefit to various "ID" fields in MySQL DB

In all of our current databases, we use a (null allowed) ID field which auto-increments at every new row insert as well as a particular member ID (unique to every person and every row). In essence, a person can be represented by ID=33 as well as MEMBERID=4839283789. I have debated completely wiping the ID field and only using the MEMB...

Clustered indexes on non-identity columns to speed up bulk inserts?

My two questions are: Can I use clustered indexes to speed up bulk inserts in big tables? Can I then still efficiently use foreign key relationships if my IDENTITY column is not the clustered index anymore? To elaborate, I have a database with a couple of very big (between 100-1000 mln rows) tables containing company data. Typically ...

How can I add inheritance to an object defined in an EntityDataModel (EF 4)?

I have a simple 2 object inheritance defined in an EF model, Person <- User. Person is the base entity/class, it is not abstract, and it contains fields like firstname, lastname, email. User is the derived entity/class, and contains fields like username, lastlogin, islockedout. The database uses a table-per-type schema, so there is ...

"There can only be one IDENTITY column per table" - Why?

"There can only be one IDENTITY column per table" Why is it so? Take a scenario of a vehicle, there exists a chasis number which is unique as well as the registration number which turns out to be unique. To depict this scenario in sql server we need a custom implementation for on of the columns. Conversely, in Oracle you can have as man...

How do you merge tables with autonumber primary keys?

I suppose everyone runs into this problem once in a while: you have two tables that have autonumber primary keys that need to be merged. There are many good reasons why autonumber primary keys are used in favour of say application-generated keys, but merging with other tables must be one of the biggest drawbacks. Some problems that aris...

Best way to move data between tables and generate mapping of old to new identity values

I need to merge data from 2 tables into a third (all having the same schema) and generate a mapping of old identity values to new ones. The obvious approach is to loop through the source tables using a cursor, inserting the old and new identity values along the way. Is there a better (possibly set-oriented) way to do this? UPDATE: One a...

Replacing PK's in Existing SQL DB Tables

Right now I have a DB where the PK's are int IDENTITY. I recently, in the last year, was tasked with adding these to a Replication Topology. This has worked out quite well with the exception of the IDENTITY fields. I want to explore my options for changing or replacing them with a uniqeidentifier(GUID). Is it feasible to insert a NEW ...

Help determining proper Identity Range sizes

I have a Merge Replication with ~200 subscribers. I am trying to determine what would be appropriate Identity Range Sizes on some of the tables. You see I inherited a DB structure that was not designed for Replication therefore all table PK's are int IDENTITY's. Unfortunately some of these tables were built WITHOUT any tracking fields...