简体   繁体   中英

SQL Server 2008 use server id as a default

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

假设您的服务器数量可能少于2 ^ 31-1,那么您可以简单地为每个服务器分配一个唯一的(32位)整数来标识它。

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

It's unambiguous, human readable and shorter then GUID

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM