sql连接服务器显示default,SQL Server 2008使用服务器标识作为默认值(SQL Server 2008 use server id as a default)...

SQL Server 2008使用服务器标识作为默认值(SQL Server 2008 use server id as a default)

我有一个存在于多个数据库中的行表。 我需要将行从一个数据库更新到另一个数据库,并且我有一个int的主键。 所以我正在寻找一种方法来唯一标识添加特定行的服务器。 我可以使用newid()或newseqentialid()在默认情况下使用uniqueidentifier,但这似乎有点过分和低效。

我想在@@ serverid的serverid列上创建一个默认值,但这不存在,我可以使用@@ servername,但这似乎对错误太明显了。 有没有办法取回服务器的guid并将其添加为列的默认值?

提前致谢

菲尔

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

原文:https://stackoverflow.com/questions/3862675

更新时间:2021-01-03 22:01

最满意答案

鉴于您可能拥有少于2 ^ 31 - 1台服务器,当然您可以简单地为每台服务器分配一个唯一的(32位)整数来识别它。

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.

相关问答

鉴于您可能拥有少于2 ^ 31 - 1台服务器,当然您可以简单地为每台服务器分配一个唯一的(32位)整数来识别它。 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.

你可以这样做: CREATE TABLE #t(col TIME DEFAULT '00:05')

INSERT #t VALUES (DEFAULT)

SELECT *

FROM #t

Tim建议更好的方法是使用TIME数据类型。 You can do it like this: CREATE TABLE #t(col TIME DEFAULT '00:05')

INSERT #t VALUES (DEFAULT)

SELECT *

FROM #t

As Tim sugges

...

newsequentialid主要用于解决表格由唯一标识符聚簇时页面碎片的问题。 您的表由一个整数列聚簇。 我设置了两个测试表,其中一个是newsequentialid列是主键,另一个是不是的(像你的那样),在主键中,GUID始终是顺序的。 另一方面,他们不是。 我不知道内部结构/技术原因为什么会出现这种情况,但是看起来很清楚,当你的表被聚集在一起时,newsequentialid()只是真正的顺序。 否则,它的行为似乎与newid()/ RowGuid类似。 另外,我很好奇你为什么要在不需要的时

...

ALTER TABLE your_table

ADD CONSTRAINT [date_def_constraint] DEFAULT ('0001-01-01') FOR [your_column]

ALTER TABLE your_table

ADD CONSTRAINT [date_def_constraint] DEFAULT ('0001-01-01') FOR [your_column]

我承认我对Sybase的经验非常有限,但它是否使用OLE DB提供程序来连接服务器? 如果是这样,是的,您应该获得连接池,因为OLE DB提供连接池。 It appears that this was a connection pooling issue. It wasn't that the connection between the linked server and SQL Server was getting reused, it was that the connections to

...

可能是这样的吗? CREATE TABLE testTbl(aColumn INT);

INSERT INTO testTbl VALUES(1),(2);

GO

CREATE VIEW vwTestTbl

AS

SELECT *,1234 applicationID

FROM testTbl;

GO

SELECT * FROM vwTestTbl;

/*

aColumn applicationID

1 1234

2 1234

*/

GO

--be aware of

...

create table #t

(

u uniqueidentifier default ('00000000-0000-0000-0000-000000000000')

)

适合我。 你是否遗漏了字面上的单引号? 这通常是不寻常的,因为通常这些列包含唯一值。 create table #t

(

u uniqueidentifier default ('00000000-0000-0000-0000-000000000000')

)

works for me. Are you missing

...

我相信我使用的密钥只检测工具是否已安装。 我将使用此密钥: SOFTWARE\Microsoft\Microsoft SQL Server\100\Bootstrap Release\1033\CurrentVersion\Version I believe the key I was using only detects if the tools are installed. I'm going to use this key: SOFTWARE\Microsoft\Microsoft SQL

...

从您的控制面板屏幕截图看,您看起来没有安装两个SQL Server实例,因此无论出于何种原因,SQL Server R2数据库引擎都未正确安装。 您应该重新运行2008R2安装程序并确保已安装或再次安装它。 From your control panel screenshot it doesn't look like you've got two SQL Server instances installed, so for whatever reason it looks like the SQL

...

此行为取决于您插入数据的方式。 如果在列中显式插入NULL,则它将采用NULL,而不是默认值。 如果您希望它采用默认值(或者,您也可以使用关键字DEFAULT 作为占位符 ),则在插入期间完全省略Book_ID列。 例如,这仍然会插入NULL: INSERT INTO [dbo].[Ayyat_Translation_Language_old_20131209]

(

[Ayat_Translation_Language_ID], ,

[Translation_Laanguage_

...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值