当我连接到本地服务器时,我收到此消息
A network-related or instance-specific error occurred while establishing a connection to
SQL Server. The server was not found or was not accessible. Verify that the instance name
is correct and that SQL Server is configured to allow remote connections. (provider:
Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft
SQL Server, Error: 2)
Run Code Online (Sandbox Code Playgroud)
这是我的登录信息:
SQL Server 服务已启动并处于运行状态。我正在连接到默认实例。
我该如何解决?
这是我的数据库脚本,
CREATE TABLE [dbo].[MyTable](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Code] [nvarchar](25) NULL,
[Name] [nvarchar](25) NULL,
[dob] [date] NULL ,
CONSTRAINT [PK_MyTable] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Run Code Online (Sandbox Code Playgroud)
当我插入时,出现此错误
Cannot insert explicit value for identity column in table 'MyTable' when
IDENTITY_INSERT is set to OFF.
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
如图所示,我有三台数据库服务器(不同的城镇位置)和客户端计算机,每台计算机都在运行软件。
这三个服务器的数据库架构是相同的。
现在我必须同步这三个服务器。
所以我将数据库上传到smarterasp.net。我想从不同的本地服务器访问这个数据库并同步每个事务(插入、更新、删除)。
我找到了SQL Server Replication并且有三种类型的复制
我应该为此使用什么方法?
或者其他更合适的方式?
注意:有时,本地服务器可能会因 Internet 连接情况而脱机。
我有带有 id(primary key - int) 和身份规范 (1,1) 的表。
我想将此列更改为uniqueidentifier
默认值 ( newid()
) 。
我尝试过的是
ALTER TABLE myTable ALTER COLUMN id uniqueidentifier default NEWID();
Run Code Online (Sandbox Code Playgroud)
但我收到了这条消息
Incorrect syntax near the keyword 'default'.
Run Code Online (Sandbox Code Playgroud)
此外,我的数据库的每个表都有id
主键列,我想通过循环或其他方式将它们更改uniqueidentifier
为默认值。newID()
sql-server primary-key uniqueidentifier sql-server-2008-r2 alter-table