开发者

SQL Server 2008 use server id as a default

开发者 https://www.devze.com 2023-01-19 05:12 出处:网络
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 unique

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 a开发者_运维百科dd it as a default on a column?

Thanks in advance

Phil


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.


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

It's unambiguous, human readable and shorter then GUID

0

精彩评论

暂无评论...
验证码 换一张
取 消