日期:2014-05-16 浏览次数:20411 次
declare
@sc_no varchar(20),
@cus_noname varchar(40),
@mem_no varchar(30),
@pass_sl varchar(10)
declare c cursor for select * from #t
open c
fetch from c into @sc_no,@cus_noname, @mem_no, @pass_sl
while(@@fetch_status = 0)
begin
update #viobill_D set sc=cast(ltrim(rtrim(sc)) as varchar)
+cast(@sc_no as varchar)+' '+ cast(@cus_noname as varchar) +' '
+cast(left(@pass_sl,charindex('.',pass_sl)-1) as varchar)+' ;'
where mem_no = @mem_no
fetch next from c into @sc_no,@cus_noname, @mem_no, @pass_sl
end;
close c
deallocate c
select * from #viobill_D
order by sc_no,mem_no
declare @sc_no?varchar(20),
????@cus_noname?varchar(40),
????@mem_no?varchar(30),
????@pass_sl?varchar(10)
declare?c?cursor?for?select?*?from?#t
????open?c
????fetch??from?c?into?@sc_no,@cus_noname,?@mem_no,?@pass_sl
????while(@@fetch_status?=?0)
????begin
????????update?#viobill_D?set?sc=ltrim(rtrim(sc))
????????????+ltrim(@sc_no)+'?'+?ltrim(@cus_noname)?+'?'
????????????+left(ltrim(@pass_sl),charindex('.',pass_sl)-1))+'?;'
????????where?mem_no?=?@mem_no
????????fetch?next?from?c?into?@sc_no,@cus_noname,?@mem_no,?@pass_sl
????end;
????close?c
????deallocate?c
?
select?*?from?#viobill_D
order?by?sc_no,mem_no