我有一個表#光標進行拆分的列#
WS_ID WS_WEBPAGE_ID WS_SPONSORS_ID WS_STATUS WS_CREATEDTS 2 3 2 N 2012-06-07 15:32:00 3 3 3 N 2012-06-07 15:37:00 4 3 4 Y 2012-06-07 15:41:00 5 1 1 Y 2012-06-07 16:05:00 6 2 1 Y 2012-06-07 16:05:00 7 2 4 Y 2012-06-07 16:05:00 8 4 1 Y 2012-06-07 16:05:00 9 1 3 Y 2012-06-07 16:05:00 10 1 2 Y 2012-06-07 16:05:00 11 1 4 Y 2012-06-07 16:05:00 12 2 3 Y 2012-06-07 16:05:00 13 2 3 Y 2012-06-07 16:05:00 14 2 1 Y 2012-06-07 16:05:00 24706 3 8,7,9,5,5 NULL NULL
我寫了一個光標,並呼籲拆分功能到光標拆分的最後一條記錄
Declare @splitc varchar(250)
Declare splitcursor cursor for
select ws_sponsors_id from dbo.TBL_WD_SPONSORS
open splitcursor
fetch next from splitcursor into @splitc
while(@@FETCH_STATUS = 0)
begin
print '@splitcursor'
--select * from dbo.Comma_Split(@ws_sponsors_id,',')
select dbo.Comma_Split(ws_sponsors_id,',') from dbo.TBL_WD_SPONSORS where ws_id = 24706
--select * from dbo.TBL_WD_SPONSORS where WS_SPONSORS_ID in(select * from dbo.Comma_Split(ws_sponsors_id,','))
fetch next from splitcursor into @splitc
end
close splitcursor
deallocate splitcursor
而且我得到錯誤
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.Comma_Split", or the name is ambiguous.
WS_ID WS_WEBPAGE_ID WS_SPONSORS_ID WS_STATUS WS_CREATEDTS 24706 3 8,7,9,5,5 NULL NULL
但I N EED輸出
WS_ID WS_WEBPAGE_ID WS_SPONSORS_ID WS_STATUS WS_CREATEDTS 24706 3 8 NULL NULL 24707 3 7 NULL NULL 24708 3 9 NULL NULL 24709 3 5 NULL NULL 24710 3 5 NULL NULL
如何獲得輸出
幫助我。
因爲格式化是不存在的,這是很難說,但是這有什麼不同[從上一個問題](http://stackoverflow.com/questions/10948396/how-to-split-the-column-values-using-stored-procedure)? –
你還在喊 – ganders