Temporary tables in SQL Server
Salut. Imi poate spune cineva unde eroare in codul urmator:CREATE PROCEDURE test1 @string nvarchar(50),@d datetimeASdrop table #temp1select t.trunk_b, t.total, r0.total as reason_0into #temp1from func_total(@d) tjoin func_reason(@d,0) r0 on r0.trunk_b=t.trunk_bDECLARE @str1 nvarchar(50), @pos int, @cause nvarchar(4)SET @str1=@stringwhile 1>0 begin set @pos=CHARINDEX(' ', @str1) set @cause='cause'+SUBSTRING(@str1,1,@pos)select * into #temp2from #temp1drop table #temp1select t.trunk_b, count(*) as total, tm.total as causeinto #temp1from tabtrafic tjoin #temp2 tm on t.trunk_b=tm.trunk_bwhere t.cause_v=@causegroup by t.trunk_b, tm.trunk_bdrop table #temp2set @str1=SUBSTRING(@str1,@pos+1,50) if @pos