# 实现数据的矩阵转换运算

/* ----------------------------------*/
/* 功能 ： 实现数据的矩阵转换运算?????? */
/* ----------------------------------*/
if exists(select name from sysobjects where xtype='p' and name='p_jzcaculate')
?? drop procedure p_jzcaculate
go
create procedure p_jzcaculate
@tablename varchar(200),
@filter varchar(400)
as
begin
? set nocount on
? declare @col nvarchar(256)
? declare @makesql nvarchar(4000)
? declare @insertsql nvarchar(4000)
? declare @caculatesql nvarchar(400)
? declare @count int
? declare @i int
? declare @j int
? declare @colid int
? create table #TempTable (colname nvarchar(20))
? select @caculatesql = 'select @count=count(1) from ' + @tablename +@filter
? exec sp_executesql @caculatesql, N'@count int output',@count output
? if @count >=1024
? begin
??? Raiserror('表的行数太多，程序无法运算',16,1)
? end
? else
? begin
??? select @i=0
??? while @count >0
??? begin
????? select @i=@i+1
????? select @makesql = 'alter table #TempTable add col'+convert(varchar(20),@i)+' varchar(40)'
????? exec(@makesql)
????? select @count=@count-1???
??? end
??? declare my_cursor cursor for
??? select name,colid from syscolumns where id=object_id(@tablename) order by colid
??? open my_cursor
??? fetch next from my_cursor into @col,@colid
??? while @@fetch_status = 0
??? begin
????? select @j=count(1) from syscolumns where id=object_id(@tablename)
????? if @colid<@j-1
????? begin
????? select @makesql ='select @insertsql= @insertsql + case
?????? when convert(varchar(400),'+@col+') is null then '''' else convert(varchar(400),'+@col+') end +'','' from ' +@tablename +@filter
????? select @insertsql =N'insert #TempTable values ('''+@col+ ','
????? execute sp_executesql @makesql,N'@insertsql nvarchar(4000) output' ,@insertsql output
????? select @insertsql = replace(left(@insertsql,len(@insertsql)-1),',',''',''') +''')'
?????? --select @insertsql
?????? -- print @makesql
????? --? exec(@makesql)
????? exec(@insertsql)
???? end
??? --? if @@error<>0
??? --? print @@error
????? fetch next from my_cursor into @col,@colid
??? end
??? close my_cursor
??? deallocate my_cursor
??? select * from #TempTable
??? set nocount off
??? drop table #TempTable
? end
end
go

exec p_jzcaculate 'CABLEINFO_jydz',' '

#### 卷积运算转换为矩阵乘法

2014-04-16 17:36:19

#### 经典数据结构之矩阵的基本运算

2013-11-24 21:05:00

#### 将卷积运算转换成矩阵相乘

2011年09月13日 286KB 下载

#### 骨骼运动变换的数学计算过程详解

2011-05-09 14:10:00

#### 微机原理与接口技术课程设计 矩阵运算程序设计

2011年06月20日 152KB 下载

#### 数据结构与算法（3）——矩阵的加、乘、转置运算实现

2015-12-07 14:47:26

#### C++中国大学mooc网----西安交大计算机程序设计第12周作业

2017-12-09 14:55:35

#### YTU 2907: 类重载实现矩阵加法

2016-01-11 15:17:09

#### 数据结构之稀疏矩阵

2018年06月11日 899B 下载

#### C实现矩阵加减乘除运算

2016-04-29 14:01:34