Hi,It's the second day I'm trying to solve this problem.I have a selection from four tables, two of columns looks like:Dovgan RiceDovgan CerealsNike BootsNike JacketNike Cap
I wanna make one more selection to make it look likeDovgan Rice, CerealsNike Boots, Jacket, Cap
It's very easy to make through function if I had rights to create table for this. But I cannot that is why I created temporary table #Zapros in Stored Procedure, fill it and trying to get only rows that looks like as I said.Stored Procedure looks like:DECLARE @Firm VARCHAR(255), @FirmProduction VARCHAR(1024)DECLARE @NextFirm VARCHAR(255), @NextFirmProduction VARCHAR(255)DECLARE cursorFirm CURSORFORSELECT Firm, FirmProduction FROM #Zapros -- this is my temporary table ORDER BY FirmOPEN cursorAgencyFETCH NEXT FROM cursorFirm into @Firm, @FirmProduction WHILE (@@FETCH_STATUS = 0)BEGINFETCH NEXT FROM cursorFirm into @NextFirm, @NextFirmProduction IF @Firm= @NextFirm BEGIN update #Zapros set #Zapros.FirmProduction = #Zapros.FirmProduction +'|' + @NextFirmProduction END SET @Firm = @NextFirmENDCLOSE cursorFirmDEALLOCATE cursorFirm
but something's going wrong and I cannot find where is a mistake. Besides this is my first Cursor. Probably someone can help me with this, or at least suggest me some direction to search in.