gpt4 book ai didi

sql-server - BACPAC 导入和临时表可能存在 BUG

转载 作者:行者123 更新时间:2023-12-02 03:12:35 26 4
gpt4 key购买 nike

我使用的是最新版本的 SQL Server 2016 Developer Edition 和 SSMS (13.0.15600.2)。

导入数据层应用程序 (bacpac) 时可能存在错误,该应用程序包含任何临时表和任何使用“WITH SCHEMABINDING”引用它们的对象(函数。 View )。

完全可以将此类数据库导出到 backpac,但在将其导入回来时出现错误:

Error SQL72014: .Net SqlClient Data Provider: Msg 3729, Level 16, State 4, Line 1 Cannot ALTER 'Table2Version' because it is being referenced by object 'BindTest'. Error SQL72045: Script execution error. The executed script: ALTER TABLE [dbo].[Table2Version] SET (SYSTEM_VERSIONING = OFF);

将重现此问题的最小数据库创建脚本是:

USE [master]
GO


CREATE DATABASE [temptest]
GO


ALTER DATABASE [temptest] SET COMPATIBILITY_LEVEL = 130
GO


USE [temptest]
GO


CREATE SCHEMA [History]
GO


CREATE TABLE [History].[Table2Version](
[Id] [int] NOT NULL,
[Name] [nvarchar](50) NULL,
[SysStartTime] [datetime2](0) NOT NULL,
[SysEndTime] [datetime2](0) NOT NULL
) ON [PRIMARY]


GO


CREATE CLUSTERED INDEX [ix_Table2Version] ON [History].[Table2Version]
([SysEndTime] ASC, [SysStartTime] ASC )
GO


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Table2Version](
[Id] [int] NOT NULL,
[Name] [nvarchar](50) NULL,
[SysStartTime] [datetime2](0) GENERATED ALWAYS AS ROW START HIDDEN NOT NULL,
[SysEndTime] [datetime2](0) GENERATED ALWAYS AS ROW END HIDDEN NOT NULL,
CONSTRAINT [PK__Table2Version] PRIMARY KEY NONCLUSTERED ( [Id] ASC ),
PERIOD FOR SYSTEM_TIME ([SysStartTime], [SysEndTime])
) ON [PRIMARY]
WITH ( SYSTEM_VERSIONING = ON (HISTORY_TABLE = [History].[Table2Version] , DATA_CONSISTENCY_CHECK = ON ))


GO


CREATE FUNCTION [dbo].[BindTest]()
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN SELECT Id AS id
from dbo.Table2Version ;



GO

这真的是一个错误还是我做错了什么?

最佳答案

关于sql-server - BACPAC 导入和临时表可能存在 BUG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39041661/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com