当我通过 C# 适配器运行此查询时,它会导致错误:
使用附近的语法不正确
有任何想法吗?当我在 SQL Server 2008 R2 中运行它时,它工作正常。
create FUNCTION [dbo].[fn_Split] (@sep nvarchar(10), @s nvarchar(4000))
RETURNS table
AS
RETURN (
WITH Pieces(pn, start, stop) AS (
SELECT 1, 1, CHARINDEX(@sep, @s)
UNION ALL
SELECT pn + 1, stop + (datalength(@sep)/2),
CHARINDEX(@sep, @s, stop + (datalength(@sep)/2))
FROM Pieces
WHERE stop > 0
)
SELECT pn,
SUBSTRING(@s, start, CASE WHEN stop > 0 THEN stop-start ELSE 4000 END) AS value
FROM Pieces
)
;
/****** Object: Table [dbo].[drillDowntable1] Script Date: 09/24/2012 18:43:32 ******/
USE [master]
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
CREATE TABLE [dbo].[drillDowntable1](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](20) NULL,
[json] [varchar](max) NULL,
[isActive] [bit] NOT NULL
) ON [PRIMARY]