我正在尝试根据特定字符从一行转换为多行 我从某人那里复制了一个脚本,该脚本正在处理他/她的示例,但对我不起作用,如下所示:
;WITH tmp(NOTEINDX, DataItem, TXTFIELD) AS
(
SELECT
NOTEINDX,
LEFT(TXTFIELD, CHARINDEX('#', TXTFIELD + '#') - 1),
STUFF(TXTFIELD, 1, CHARINDEX('#', TXTFIELD + '#'), '')
FROM SY03900
UNION all
SELECT
NOTEINDX,
LEFT(TXTFIELD, CHARINDEX('#', TXTFIELD + '#') - 1),
STUFF(TXTFIELD, 1, CHARINDEX(',', TXTFIELD + '#'), '')
FROM tmp
WHERE
TXTFIELD > ''
)
SELECT
NOTEINDX,
DataItem
FROM tmp
ORDER BY NOTEINDX
但是我遇到错误
Msg 402, Level 16, State 1, Line 6
The data types text and varchar are incompatible in the add operator.
我正在使用SQL Server 2008 谢谢, 哈蒂姆