从SQL Server链接表中错误地映射主键

时间:2016-07-05 14:57:08

标签: sql-server ms-access odbc mapping primary-key

我有一个链接到Access 2016前端的SQL Server后端数据库。其中一个表是在将表链接到Access时错误地映射了它的主键。

主键应该是RegistrationID,这在GUI中的SQL Server中都是正确的(我可以看到此字段旁边的键图标),并且在脚本中。但是,当我将此表链接到Access时,主键会自动且错误地映射到ROWGUID,从而导致各种麻烦。

我该如何解决这个问题?

这是表格的设计

USE [BlinkDataMaster2015]
GO

/****** Object:  Table [dbo].[TrnRegistration]    Script Date: 7/5/2016     5:36:24 AM ******/
SET ANSI_NULLS ON  
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[TrnRegistration](
    [fkClassSchedID] [int] NULL,
    [fkCompanyID] [int] NULL,
    [NumberUsers] [int] NULL,
    [Notes] [nvarchar](max) NULL,
    [Contact] [nvarchar](50) NULL,
    [fkUserTypeID] [int] NULL,
    [fkOrderTypeID] [int] NULL,
    [OrderRef] [nvarchar](50) NULL,
    [FloatClassID] [int] NULL,
    [LocFrstID] [int] NULL,
    [LocScndID] [int] NULL,
    [SalesRep] [int] NULL,
    [RegistrationID] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
    [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT     [MSmerge_df_rowguid_7172B8EB13CC4A729BB49A8735FC0B54]  DEFAULT     (newsequentialid()),
    [VerifDate] [bit] NOT NULL,
 CONSTRAINT [PK_TrnRegistration] PRIMARY KEY NONCLUSTERED 
(
    [RegistrationID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,     ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

ALTER TABLE [dbo].[TrnRegistration]  WITH CHECK ADD  CONSTRAINT     [FK_TrnRegistration_Customers] FOREIGN KEY([fkCompanyID])
REFERENCES [dbo].[Customers] ([ID])
GO

ALTER TABLE [dbo].[TrnRegistration] CHECK CONSTRAINT     [FK_TrnRegistration_Customers]
GO

ALTER TABLE [dbo].[TrnRegistration]  WITH CHECK ADD  CONSTRAINT     [FK_TrnRegistration_TrnClassSched] FOREIGN KEY([fkClassSchedID])
REFERENCES [dbo].[TrnClassSched] ([ClassSchedID])
GO

ALTER TABLE [dbo].[TrnRegistration] CHECK CONSTRAINT     [FK_TrnRegistration_TrnClassSched]
GO

ALTER TABLE [dbo].[TrnRegistration]  WITH CHECK ADD  CONSTRAINT     [FK_TrnRegistration_TrnOrderType] FOREIGN KEY([fkOrderTypeID])
REFERENCES [dbo].[TrnOrderType] ([OrderTypeID])
GO

ALTER TABLE [dbo].[TrnRegistration] CHECK CONSTRAINT     [FK_TrnRegistration_TrnOrderType]
GO

ALTER TABLE [dbo].[TrnRegistration]  WITH CHECK ADD  CONSTRAINT     [FK_TrnRegistration_TrnUserType] FOREIGN KEY([fkUserTypeID])
REFERENCES [dbo].[TrnUserType] ([UserTypeID])
GO

ALTER TABLE [dbo].[TrnRegistration] CHECK CONSTRAINT     [FK_TrnRegistration_TrnUserType]
GO

ALTER TABLE [dbo].[TrnRegistration]  WITH NOCHECK ADD  CONSTRAINT     [repl_identity_range_7AF383DC_269D_4D8C_8E18_2796713D8E44] CHECK NOT FOR     REPLICATION (([RegistrationID]>(516793) AND [RegistrationID]<=(517793) OR     [RegistrationID]>(541793) AND [RegistrationID]<=(542793)))
GO

ALTER TABLE [dbo].[TrnRegistration] CHECK CONSTRAINT     [repl_identity_range_7AF383DC_269D_4D8C_8E18_2796713D8E44]
GO

0 个答案:

没有答案