1、SQL实现动态交叉表>>教育资源库 SETQUOTED_IDENTIFIERON GO SETANSI_NULLSON GO ALTER procedureCrossTable strTableNameasvarchar(50)='', --查询表 strColasvarchar(50)='', strGroupasvarchar(50)='',--分组字段 strNumberasvarchar(50)='',--被统计的字段 strputeasvarchar(50)='
2、Sum'--运算方式 as declarestrSqlasvarchar(1000),strTempColasvarchar(100) execute('DECLAREcorss_cursorCURSORFORSELECTDISTINCT'+strCol+'from'+strTableName+'forreadonly')--生成游标 begin setnocounton setstrSql='select'+strGroup+','+strpute+'
4、39;]' end setstrsql=strSql+'from'+strTableName+'groupby'+strGroup printstrSql execute(strSql) iferror<>0returnerror printerror closecorss_cursor deallocatecorss_cursorreturn0 end GO SETQUOTED_IDENTIFIEROFF GO SETANSI_NULLSON GO>>>>这篇文章来自..,。