RowID-Can two rows have a same row id??

  • I have sqlserver installed in a remote place and also at my place.Our tables have unique row id (system generated)

    For any insertion/modification to remote office db, a trigger will be written which will capture data with the rowid in a separate table.The sep. table will be converted into flat file and transfered to my place.The files will be inserted into my db automatically using BCP facility.

    My question is, are there chances of the system generating an unique id which is already created by my remote office sql server.If yes, I think there will be some violation problem. During consolidation of my remote location and my db, can two rows have a same row id?

    For example: I have a rowid: 1ab2c(unique to my db table)

    Are there chances of my state sqlserver generating the same rowid?

    Help me.

    Chokks.

  • What is generating the key? If you use a data type of uniqueidentifier, duplicates are never supposed to happen since a guid is some combination of network mac address, date/time, computer name. If you're using identity then you have to manage the ranges used on each machine. If you're doing it yourself then an easy way (using string keys) is to just a prefix unique to that location to the key.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • I like using the GUID best, but if you cannot change your table to use a uniqueidentifier then another trick is to use an Instead Of trigger on the table at the home office.

    My assumptions here are:

    1) The unique row id is an identity column.

    2) You don't care if the id is the same at the remote office and the home office as long as the id is unique.

    Your instead of trigger would just exclude the identity column from the insert statement and let the home office generate its own identity.

    Brian

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply