1、SQL实现动态交叉表>> SETQUOTED_IDENTIFIERON GO SETANSI_NULLSON GO ALTER procedureCrossTable strTableNameasvarchar(50)='', --查询表 strColasvarchar(50)='', strGroupasvarchar(50)='',--分组字段 strNumberasvarchar(50)='',--被统计的字段 str
2、puteasvarchar(50)='Sum'--运算方式 as declarestrSqlasvarchar(1000),strTempColasvarchar(100) execute('DECLAREcorss_cursorCURSORFORSELECTDISTINCT'+strCol+'from'+strTableName+'forreadonly')--生成游标 begin setnocounton setstrSql=