日期:2014-05-19  浏览次数:20401 次

继续问
代码是一位大侠提供的,老是提示
服务器:   消息   137,级别   15,状态   2,行   54
必须声明变量   '@ '。

go
if   object_id( 'SHSFXQXXHWYHCARD..C ')   is   not   null
      drop   table   C
go
create   table   C(a5   varchar(20),b5   varchar(20))
insert   into   C(a5,b5)   values( 'ZWW-XJG ', '1-040901 ')
insert   into   C(a5,b5)   values( 'ZWW-JF ', '1-040901 ')
insert   into   C(a5,b5)   values( 'ZWW-NTPC ', '1-040901 ')
insert   into   C(a5,b5)   values( 'ZWW-PC ', '1-040901 ')
insert   into   C(a5,b5)   values( 'ZSW04 ', '1-050401 ')
insert   into   C(a5,b5)   values( 'ZSW05 ', '1-050401 ')
insert   into   C(a5,b5)   values( 'ZWW-YBY ', '1-050602 ')
insert   into   C(a5,b5)   values( 'ZWW-JCYYW ', '1-050603 ')
insert   into   C(a5,b5)   values( 'GWW-JCYYW ', '2-050603 ')
insert   into   C(a5,b5)   values( 'ZWW-GDW ', '1-050704 ')
insert   into   C(a5,b5)   values( 'GWW-GDW ', '2-050704 ')
insert   into   C(a5,b5)   values( 'ZWW-VOD ', '1-050805 ')
insert   into   C(a5,b5)   values( 'ZWW-RMFY ', '1-050906 ')
insert   into   C(a5,b5)   values( 'MHWZ ', '3-051007 ')
insert   into   C(a5,b5)   values( 'ZWW-DZYZ-001 ', '1-051008 ')
insert   into   C(a5,b5)   values( 'ZWW-SWJIT ', '1-060401 ')
insert   into   C(a5,b5)   values( 'ZWW-YJZH ', '1-060402 ')
insert   into   C(a5,b5)   values( 'ZWW-JYC ', '1-060403 ')
insert   into   C(a5,b5)   values( 'ZWW-GIS ', '1-060504 ')
insert   into   C(a5,b5)   values( 'ZWW-CXW ', '1-060505 ')
insert   into   C(a5,b5)   values( 'ZWW-JSWFW ', '1-060506 ')
insert   into   C(a5,b5)   values( 'ZWW-JG ', '1-060709 ')
insert   into   C(a5,b5)   values( 'ZWW-RDZXTA ', '1-060811 ')
insert   into   C(a5,b5)   values( 'ZZBXXGLXT ', '1-060812 ')
insert   into   C(a5,b5)   values( 'ZWW-JCYDA ', '1-060813 ')
insert   into   C(a5,b5)   values( 'ZWW-WZBWZ ', '1-061116 ')
insert   into   C(a5,b5)   values( 'ZWW-YJSJ ', '1-061121 ')
insert   into   C(a5,b5)   values( 'ZWW-DZYZ-003 ', '1-061122 ')
insert   into   C(a5,b5)   values( 'ZWW-FBDRJ ', '1-061223 ')
insert   into   C(a5,b5)   values( 'ZWW-ZBRJ ', '1-060324 ')
insert   into   C(a5,b5)   values( 'ZWW-SFJ-002 ', '1-061025 ')
go
if   object_id( 'SHSFXQXXHWYHCARD..D ')   is   not   null
      drop   table   D
go
select   id   =   identity(int,1,1)   ,   *   into   D   from   FA_Kp
declare   @count   as   int
select   @count   =   count(*)   from   D
declare   @i   as   int
set   @i   =   1
declare   @s2   as