SQL Server 2008 Spatial不允许链接表

时间:2011-12-07 18:47:21

标签: sql sql-server-2008

我有两个表在SQL Server 2008 Standard 64位中具有完全相同的模式,但有一个例外:一个是您的“基本”表,一个用于存储SQL Server Spatial格式的地理数据。我已经包含了SQL来生成表。

我们有一个任务要求客户​​端通过链接表通过M $ Access前端访问这些表(理想情况下只有一个表,具有M $ Spatial选项)。这个数据库包含几个其他表,通过链接表在Access中工作得很好,dbo.non_spatial也可以正常工作。但是,在尝试在访问dbo.spatial时创建链接表时,dbo.spatial会在Access“-7477”中返回错误,并且表格不会链接。我已尝试在DSN,文件,用户,系统,转向跟踪中的每个可能的选项排列,并且没有错误显示自己的线索。通过将dbo.spatial重新创建为dbo.non_spatial,链接表可以正常工作,这使我相信Microsoft Spatial Schema不能作为链接表用于Access。我找不到任何证明这一点的文件。我尝试了一个没有Shape [geometry]列的视图,Access可以看到要链接到它的表,但是在Access中填充视图需要20-30分钟,而且我对使用视图作为变通方法并不感兴趣,因为这将导致必须维护更多空间表的视图。那么....我如何链接到Access中的SQL空间表?

/****** create a non-spatial table******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[non_spatial]
    [OBJECTID] [int] NOT NULL,
    [FCategory] [nvarchar](16) NOT NULL,
    [MapMethod] [nvarchar](4) NOT NULL,
    [HError] [nvarchar](50) NOT NULL,
    [MapSource] [nvarchar](255) NULL,
    [SourceDate] [datetime2](7) NULL,
    [EditDate] [datetime2](7) NOT NULL,
    [Notes] [nvarchar](255) NULL,
    [Species_Community] [nvarchar](50) NOT NULL,
    [Location_ID] [uniqueidentifier] NOT NULL,
    [Site_ID] [uniqueidentifier] NULL,
    [GIS_Location_ID] [nvarchar](50) NULL,
    [Meta_MID] [nvarchar](50) NULL,
    [X_Coord] [numeric](38, 8) NULL,
    [Y_Coord] [numeric](38, 8) NULL,
    [Coord_Units] [nvarchar](50) NULL,
    [Coord_System] [nvarchar](50) NULL,
    [UTM_Zone] [nvarchar](50) NULL,
    [Accuracy_Notes] [nvarchar](255) NULL,
    [Unit_Code] [nvarchar](12) NULL,
    [Loc_Name] [nvarchar](100) NULL,
    [Loc_Type] [nvarchar](25) NULL,
    [Updated_Date] [nvarchar](50) NULL,
    [Loc_Notes] [nvarchar](255) NULL,
    [Datum] [nvarchar](5) NULL,
    [Watershed] [nvarchar](50) NULL,
    [StreamName] [nvarchar](50) NULL,
    [NHDReachCode] [nvarchar](14) NULL,
    [TOPO_NAME] [nvarchar](50) NULL,
    [Trail] [nvarchar](100) NULL,
    [Road] [nvarchar](50) NULL,
    [Elevation] [numeric](38, 8) NULL,
    [LAT] [numeric](38, 8) NULL,
    [LON] [numeric](38, 8) NULL,
    [Population_ID] [uniqueidentifier] NULL,
    [Year_] [nvarchar](4) NULL,
    [WGS_DAT] [nvarchar](5) NULL,
    [WGS_CS] [nvarchar](5) NULL,
    [County] [nvarchar](20) NULL,
    [State] [nvarchar](15) NULL,
    [IsExtant] [nvarchar](3) NULL,
    [IsSenstive] [nvarchar](3) NULL,
    [SpeciesName] [nvarchar](125) NULL,
    [SpeciesID] [nvarchar](50) NULL,
    [Species_ID] [int] NULL,
    [Shape] [int] NULL
) ON [PRIMARY]

GO

********************************************************************
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[spatial](
    [OBJECTID] [int] NOT NULL,
    [FCategory] [nvarchar](16) NOT NULL,
    [MapMethod] [nvarchar](4) NOT NULL,
    [HError] [nvarchar](50) NOT NULL,
    [MapSource] [nvarchar](255) NULL,
    [SourceDate] [datetime2](7) NULL,
    [EditDate] [datetime2](7) NOT NULL,
    [Notes] [nvarchar](255) NULL,
    [Species_Community] [nvarchar](50) NOT NULL,
    [Location_ID] [uniqueidentifier] NOT NULL,
    [Site_ID] [uniqueidentifier] NULL,
    [GIS_Location_ID] [nvarchar](50) NULL,
    [Meta_MID] [nvarchar](50) NULL,
    [X_Coord] [numeric](38, 8) NULL,
    [Y_Coord] [numeric](38, 8) NULL,
    [Coord_Units] [nvarchar](50) NULL,
    [Coord_System] [nvarchar](50) NULL,
    [UTM_Zone] [nvarchar](50) NULL,
    [Accuracy_Notes] [nvarchar](255) NULL,
    [Unit_Code] [nvarchar](12) NULL,
    [Loc_Name] [nvarchar](100) NULL,
    [Loc_Type] [nvarchar](25) NULL,
    [Updated_Date] [nvarchar](50) NULL,
    [Loc_Notes] [nvarchar](255) NULL,
    [Datum] [nvarchar](5) NULL,
    [Watershed] [nvarchar](50) NULL,
    [StreamName] [nvarchar](50) NULL,
    [NHDReachCode] [nvarchar](14) NULL,
    [TOPO_NAME] [nvarchar](50) NULL,
    [Trail] [nvarchar](100) NULL,
    [Road] [nvarchar](50) NULL,
    [Elevation] [numeric](38, 8) NULL,
    [LAT] [numeric](38, 8) NULL,
    [LON] [numeric](38, 8) NULL,
    [Population_ID] [uniqueidentifier] NULL,
    [Year_] [nvarchar](4) NULL,
    [WGS_DAT] [nvarchar](5) NULL,
    [WGS_CS] [nvarchar](5) NULL,
    [County] [nvarchar](20) NULL,
    [State] [nvarchar](15) NULL,
    [IsExtant] [nvarchar](3) NULL,
    [IsSenstive] [nvarchar](3) NULL,
    [SpeciesName] [nvarchar](125) NULL,
    [SpeciesID] [nvarchar](50) NULL,
    [Species_ID] [int] NULL,
    [Shape] [geometry] NULL,
 CONSTRAINT [R26_pk] PRIMARY KEY CLUSTERED 
(
    [OBJECTID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 75) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[spatial]  WITH CHECK ADD  CONSTRAINT [g6_ck] CHECK  (([SHAPE].[STSrid]=(26917)))
GO

ALTER TABLE [dbo].[spatial] CHECK CONSTRAINT [g6_ck]
GO

在Access中,您可以链接到non_spatial但无法链接到spatial!

1 个答案:

答案 0 :(得分:1)

事实证明,这是一个记录在案的“功能”!解决方法是创建没有几何列的视图,并链接到视图