当前位置: 代码迷 >> Sql Server >> 怎么实现用游标实现批处理修改SQL表的一列数据
  详细解决方案

怎么实现用游标实现批处理修改SQL表的一列数据

热度:89   发布时间:2016-04-27 17:39:41.0
如何实现用游标实现批处理修改SQL表的一列数据
表有3列,分别为A,B,C.
A列中有许多重复项,例如:a,a,a,a,c,c,c,b,r,f,f,f.....这样
B列没有重复项.
C列是a,a,a,a们的一个序列号1,2,3,4...

A               B                 C
a               .                 1            
a               .                 2                                                        
a               .                 3                                  
a               .                 4                        
c               .                 1                            
c               .                 2                  
c               .                 3                            
b               .                 1                                      
r               .                 1              
f               .                 1            
f               .                 2      
f               .                 2                              
.               .                 .            
.

请问如和使用游标修改C列....谢谢达人指教



------解决方案--------------------
declare @a table(A char(1), B varchar(10), C int)
insert @a select 'a ', 'wq ', 1
union all select 'a ', 'ee ',2
union all select 'a ', 'r3 ',3
union all select 'a ', 'sdr ',4
union all select 'c ', 'fas ',1
union all select 'c ', 'fd ',2
union all select 'c ', '2df ',3
union all select 'b ', '2fdsd ',1
union all select 'r ', 'fasd ',1
union all select 'f ', 'gs ',1
union all select 'f ', '2sdf ',2
union all select 'f ', 'hgds ',2
  相关解决方案