测试proc

Create proc Pro_TGWTOByQSF as DECLARE @Name varchar(500) DECLARE contact_cursor CURSOR FOR select distinct 起诉方 from V_LawCaseContent_10 where charindex(',',起诉方)>0 OPEN contact_cursor declare @sql varchar(8000) set @sql='select * into #tt from (' FETCH NEXT FROM contact_cursor INTO @Name WHILE @@FETCH_STATUS = 0 BEGIN set @sql=@sql+'select * from Fnsplit('''+@Name+''','','') union all ' FETCH NEXT FROM contact_cursor INTO @Name END set @sql=@sql+' select 起诉方 from V_LawCaseContent_10 where charindex('','',起诉方)=0 ) temps' set @sql=@sql+' select top 10 count(1) 数量,a as 申诉方 from #tt group by a order by 数量 desc' set @sql=@sql+' drop table #tt' exec (@sql) CLOSE contact_cursor DEALLOCATE contact_cursor GO

你可能感兴趣的:(sql,Go,申诉)