views:

25

answers:

2

Hi

I have a tables of rows that exists in multiple databases. I will need to update the rows from one database into the other database and I have a primary key of int. So I am looking for a way to uniquely identify the server that added a particular row. I could use a uniqueidentifier in a default using the newid() or newseqentialid() but this seems overkill and inefficient.

I would like to create a default value on a column of serverid of @@serverid but this doesn't exist, I could use @@servername but this seems too obvious to errors. Is there any way to get back a guid for the server and add it as a default on a column?

Thanks in advance

Phil

A: 

Given that you are likely to have less then 2^31 - 1 servers, surely you can simply assign a unique (32 bit) integer to each server to identify it.

Mitch Wheat
A: 

I'd just use @@SERVERNAME or a tabe based on this.

It's unambiguous, human readable and shorter then GUID

gbn
Is server name guaranteed to be unique on a network?
Mitch Wheat
Mitch Wheat: unique enough for practical purposes, no? Quite careless if you manage to have duplicate server names in different domains.
gbn