SQL AZURE:执行GlobalQuery操作时发生错误:大对象列支持仅限于nvarchar(max)数据类型

时间:2016-10-25 06:23:38

标签: sql azure azure-sql-database

Sql azure查询:创建外部表后我运行select查询从外部表中获取数据,但发生此错误! 我删除了所有具有datatype = nvarchar(max)的列,但问题还没有解决!

创建外部表的代码:

CREATE External TABLE [dbo].[tbl_threads_controlPanel_v](
    [thread_id] [varchar](6) NOT NULL,
    [thread_desc_criteria] [varchar](300) NOT NULL,
    [thread_desc_formula] [varchar](300) NOT NULL,
    [thread_type] [char](1) NOT NULL,
    [detectType] [char](1) NOT NULL,
    [detailed_qry] [nvarchar](300) NULL,
    [bottomup_qry] [nvarchar](300) NULL,
    [period_desc] [char](1) NULL,
    [period_value] [int] NULL,
    [period_value_range] [varchar](50) NULL,
    --[cond_attribute] [nvarchar](max) NULL,
    [cond_min_max_limit] [varchar](30) NULL,
    [cond_desc] [varchar](60) NULL,
    [active] [char](1) NULL,
    [mature] [char](1) NULL,
    [pkg_run] [char](1) NULL,
    [thread_index] [int] NULL,
    [thread_weight] [numeric](12, 11) NULL,
    [thread_noti_type] [char](1) NULL,
    [notif_id] [varchar](9) NULL,
    [amt_type] [nchar](5) NULL--,
    --[report_Columns] [nvarchar](max) NULL,
    --[OS_Columns] [nvarchar](max) NULL
)
with(DATA_SOURCE = MyElasticDBQueryDataSrc3)

这是选择查询:

select * from dbo.[tbl_threads_controlPanel_v]

请帮助..

提前致谢。

更新2: 这是原始的tbl_threads定义 使用[DB_IFDPS_ControlPanel] GO

/****** Object:  Table [dbo].[tbl_threads]    Script Date: 10/26/2016 8:51:09 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[tbl_threads](
    [thread_id] [varchar](6) NOT NULL,
    [thread_desc_criteria] [varchar](300) NOT NULL,
    [thread_desc_formula] [varchar](300) NOT NULL,
    [thread_type] [char](1) NOT NULL,
    [detectType] [char](1) NOT NULL,
    [detailed_qry] [text] NULL,
    [bottomup_qry] [text] NULL,
    [period_desc] [char](1) NULL,
    [period_value] [int] NULL,
    [period_value_range] [varchar](50) NULL,
    [cond_attribute] [nvarchar](max) NULL,
    [cond_min_max_limit] [varchar](30) NULL,
    [cond_desc] [varchar](60) NULL,
    [active] [char](1) NULL,
    [mature] [char](1) NULL,
    [pkg_run] [char](1) NULL,
    [thread_index] [int] NULL,
    [thread_weight] [numeric](12, 11) NULL,
    [thread_noti_type] [char](1) NULL,
    [notif_id] [varchar](9) NULL,
    [amt_type] [nchar](5) NULL,
    [report_Columns] [nvarchar](max) NULL,
    [OS_Columns] [nvarchar](max) NULL,
 CONSTRAINT [PK_tbl_threads] PRIMARY KEY CLUSTERED 
(
    [thread_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] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

1 个答案:

答案 0 :(得分:1)

看起来这不是整个故事。 问题似乎不在于varchar(max)列,而是在其他地方定义为LOB的列,但在外部表中定义的是varchar(max)

感谢您添加相关的DDL。

问题很可能出在 text

CREATE External TABLE [dbo].[tbl_threads_controlPanel_v](
...
[detailed_qry] [nvarchar](300) NULL,
[bottomup_qry] [nvarchar](300) NULL,
...
CREATE TABLE [dbo].[tbl_threads]
...
[detailed_qry] [text] NULL,
[bottomup_qry] [text] NULL,   
...

P.S。

https://msdn.microsoft.com/en-us/library/ms187993.aspx

重要!将来的SQL Server版本中将删除ntext,text和image数据类型。避免在新的开发工作中使用这些数据类型,并计划修改当前使用它们的应用程序。请改用nvarchar(max),varchar(max)和varbinary(max)。