这个SQL存储过程是从旧表插如到新表的基础档案,执行成功但不见任何插入的档案数据!求大神解答,赠高分
createproc[dbo].[p_zhangtao]@zt1sysname,@zt2sysnameasdeclare@CHIMAvarchar(1000),@YANS...
create proc [dbo].[p_zhangtao]
@zt1 sysname,
@zt2 sysname
as
declare @CHIMA varchar(1000),
@YANSE varchar(1000),
@pinpai varchar(1000),
@jijie varchar(1000),
@hpdw varchar(1000),
@hpks varchar(1000),
@hpzl varchar(1000),
@hpxx varchar(1000),
@hpys varchar(1000),
@hpcm varchar(1000),
@kehu varchar(1000),
@cangku varchar(1000),
@ghs varchar(1000),
@zdydyb varchar(1000),
@hpnf varchar(1000)
set @yanse='insert into @zt2..yanse select * from @zt1..yanse'
set @CHIMA='insert into @zt2..chima select * from @zt1..chima'
set @pinpai='insert into @zt2..pinpai select * from @zt1..pinpai'
set @jijie='insert into @zt2..jijie select * from @zt1..jijie'
set @hpdw='insert into @zt2..hpdw select * from @zt1..hpdw'
set @hpzl='insert into @zt2..hpzl select * from @zt1..hpzl'
set @hpnf='insert into @zt2..hpnf select * from @zt1..hpnf'
set @hpks='insert into @zt2..hpks select * from @zt1..hpks'
set @hpxx='insert into @zt2..hpxx select * from @zt1..hpxx'
set @hpys='insert into @zt2..hpys select * from @zt1..hpys'
set @hpcm='insert into @zt2..hpcm select * from @zt1..hpcm'
set @kehu='insert into @zt2..kehu select * from @zt1..kehu where khdm<>''000'''
set @ghs='insert into @zt2..ghs select * from @zt1..ghs'
set @cangku='insert into @zt2..cangku select * from @zt1..cangku'
set @zdydyb='insert into @zt2..zdydyb select * from @zt1..zdydyb' 展开
@zt1 sysname,
@zt2 sysname
as
declare @CHIMA varchar(1000),
@YANSE varchar(1000),
@pinpai varchar(1000),
@jijie varchar(1000),
@hpdw varchar(1000),
@hpks varchar(1000),
@hpzl varchar(1000),
@hpxx varchar(1000),
@hpys varchar(1000),
@hpcm varchar(1000),
@kehu varchar(1000),
@cangku varchar(1000),
@ghs varchar(1000),
@zdydyb varchar(1000),
@hpnf varchar(1000)
set @yanse='insert into @zt2..yanse select * from @zt1..yanse'
set @CHIMA='insert into @zt2..chima select * from @zt1..chima'
set @pinpai='insert into @zt2..pinpai select * from @zt1..pinpai'
set @jijie='insert into @zt2..jijie select * from @zt1..jijie'
set @hpdw='insert into @zt2..hpdw select * from @zt1..hpdw'
set @hpzl='insert into @zt2..hpzl select * from @zt1..hpzl'
set @hpnf='insert into @zt2..hpnf select * from @zt1..hpnf'
set @hpks='insert into @zt2..hpks select * from @zt1..hpks'
set @hpxx='insert into @zt2..hpxx select * from @zt1..hpxx'
set @hpys='insert into @zt2..hpys select * from @zt1..hpys'
set @hpcm='insert into @zt2..hpcm select * from @zt1..hpcm'
set @kehu='insert into @zt2..kehu select * from @zt1..kehu where khdm<>''000'''
set @ghs='insert into @zt2..ghs select * from @zt1..ghs'
set @cangku='insert into @zt2..cangku select * from @zt1..cangku'
set @zdydyb='insert into @zt2..zdydyb select * from @zt1..zdydyb' 展开
2个回答
展开全部
@zt1 sysname,
@zt2 sysname
定义为字符串,宏慎应该是你数据库的名称
insert into @zt2..yanse select * from @zt1..yanse
根本不用赋值到字符串,你复制到字符串又没有执行字符蔽肢敬串的内容,当饥胡然就没有数据导入了
其它你照猫画虎,注意新旧数据库的表结构是否一致
@zt2 sysname
定义为字符串,宏慎应该是你数据库的名称
insert into @zt2..yanse select * from @zt1..yanse
根本不用赋值到字符串,你复制到字符串又没有执行字符蔽肢敬串的内容,当饥胡然就没有数据导入了
其它你照猫画虎,注意新旧数据库的表结构是否一致
更多追问追答
追问
怎么执行字符串的内容,后面怎么写呢
追答
exec(@sql)
这样才会执行字符串里面的sql语句
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询