存储过程的问题
CREATE procedure nianjie
@gsmc varchar(200)
as
begin
declare @zhangbiao as varchar(20)
declare @djb as varchar(20)
select @zhangbiao=zhangbiao,@djb=djb from gongsibiao where gsmc=@gsmc and nian=year(getdate()-1)
exec( 'insert into qcliushuizh(djh,gsmc,jlh,ckmc,wpbh,shliang,bhsdj,hsdj,bhsje,shuier,zjiner) select [ '+@zhangbiao+ '].djh,gsmc,[ '+@zhangbiao+ '].jlh,ckmc,wpbh,shliang,bhsdj,hsdj,bhsje,shuier,zjiner from [ '+@zhangbiao+ '],[ '+@djb+ '] where gsmc= ' ' '+@gsmc+ ' ' ' and [ '+@zhangbiao+ '].zfbz=0 and [ '+@djb+ '].zfbz=0 and [ '+@zhangbiao+ '].djh=[ '+@djb+ '].djh and (fph is null or fph= ' ') and czlx in ( ' '采购进货 ' ', ' '采购退货 ' ', ' '调入 ' ')
')
end
go
exec nianjie 'AAA '
提示这个错误啊
服务器: 消息 170,级别 15,状态 1,行 1
第 1 行: '采购进货 ' 附近有语法错误。
服务器: 消息 105,级别 15,状态 1,行 1
字符串 ')
' 之前有未闭合的引号。
[解决办法]
czlx in ( ' ' '采购进货 ' ' ', ' ' '采购退货 ' ' ', ' ' '调入 ' ' ')
这里改下试试``
[解决办法]
exec( 'insert into qcliushuizh(djh,gsmc,jlh,ckmc,wpbh,shliang,bhsdj,hsdj,bhsje,shuier,zjiner) select [ '+@zhangbiao+ '].djh,gsmc,[ '+@zhangbiao+ '].jlh,ckmc,wpbh,shliang,bhsdj,hsdj,bhsje,shuier,zjiner from [ '+@zhangbiao+ '],[ '+@djb+ '] where gsmc= ' ' '+@gsmc+ ' ' ' and [ '+@zhangbiao+ '].zfbz=0 and [ '+@djb+ '].zfbz=0 and [ '+@zhangbiao+ '].djh=[ '+@djb+ '].djh and (fph is null or fph= ' ' ' ') and czlx in ( ' '采购进货 ' ', ' '采购退货 ' ', ' '调入 ' ') ')