sqlserver2005 游标 CityTotalSales表结构
mobile varchar(20)
CityCode varchar (10)
TotalSales int
regtotal int
region varchar (50)
数据
mobile citycode totalsales regtotal region
18316998988 BJ 387 631 E
18316998988 SH 124 631 E
18316998988 TJ 88 631 E
18316998988 NMG 32 631 E
18316998988 GZ 333 995 N
18316998988 GZ 333 995 N
13658754144 SZ 425 995 N
13658754144 HZ 123 995 N
13658754144 DG 114 995 N
--测试数据准备
if(object_id('t1') is not null)drop table t1
CREATE table t1(
id int identity(1,1) primary key,
value nvarchar(20)
)
go
--插入测试数据
insert into t1(value)
select '值1'union all
select '值2'union all
select '值3'union all
select '值4'
--查看结果集合
--select * from t1
if(OBJECT_ID('p_print')is not null) drop procedure p_print
go
create procedure p_print
as
begin
declare @value nvarchar(20)--注意这里的变量类型应该与游标中读取出来的字段类型相同
&nbs