我之前已经意识到这个问题,但是由于某些原因我无法让它工作.
我正在使用此SQL Team线程中的split函数(第二篇文章)和以下查询.
--This query converts the interests field from text to varchar
select
cp.id
,cast(cp.interests as varchar(100)) as interests
into #client_profile_temp
from
client_profile cp
--This query is supposed to split the csv ("Golf","food") into multiple rows
select
cpt.id
,split.data
from
#client_profile_temp cpt
cross apply dbo.split(
cpt.interests, ',') as split <--Error is on this line
Run Code Online (Sandbox Code Playgroud)
但是我得到了一个
Incorrect syntax near '.'
Run Code Online (Sandbox Code Playgroud)
我在上面标出的错误.
最后,我想要
ID INTERESTS
000CT00002UA "Golf","food"
Run Code Online (Sandbox Code Playgroud)
成为
ID INTERESTS
000CT00002UA "Golf"
000CT00002UA "food"
Run Code Online (Sandbox Code Playgroud)
我正在使用SQL Server 2008,并根据StackOverflow问题得出答案.我对SQL很陌生,所以任何其他智慧的话也会受到赞赏.
sql-server ×1