SQL存储过程实现SPSS交叉表(有图有真相)(二)

2014-11-24 01:39:28 · 作者: · 浏览: 7
as colName1,convert(nvarchar(255),colName2) as colName2,Value from Temp_CrossTable_001 m ) P PIVOT ( SUM(Value) FOR colName1 IN ('+ @str1 +') ) AS T ) t ') exec (@str) set @str =' --if object_id(N''[Out_CrossTable_Percent]'',N''U'') is not null begin drop table [Out_CrossTable_Percent] end select t1.colName2 as '+@colName2+' , '+@str4+' --into Out_CrossTable_Percent from Out_CrossTable_Value t1 ,( select '+@str1+' from Out_CrossTable_Value where colName2=''sum_col'') t2 ' exec (@str) --------------------------------------结果: --select * from Out_CrossTable_Percent commit tran return 0 end try begin catch rollback tran return 1 end catch end
调用SP:

\