存储过程不支持字符相吗??那条件怎么区别呀?晕
CREATE proc stfd @zid varchar(500),
@za int,
@zb int,
@zc int
as
declare @strS varchar(5000)
begin
set @strS='update info set za='+cast(@za as varchar)
begin
if @zb != ''
set @strS=@strS+', zb= '+cast(@zb as varchar)
end
begin
if @zc != ''
set @strS=@strS+', zc= '+cast(@zc as varchar)
end
set @strS=@strS+' where id in ('+@zid+')'
end
exec (@strS)
go
以上只有za字段能改变,zb,zc里的值怎么又不变,晕,但是,下边这种也能变:
CREATE proc stfd
@zid varchar(500),
@za int,
@zb int,
@zc int
as
declare @strS varchar(5000)
begin
set @strS='update info set za='+cast(@za as varchar)
begin
if @zb != '' 去掉这行,那这时zb也能改变了
set @strS=@strS+', zb= '+cast(@zb as varchar)
end
begin
if @zc != ''
set @strS=@strS+', zc= '+cast(@zc as varchar)
end
set @strS=@strS+' where id in ('+@zid+')'
end
exec (@strS)
go
我用个if 来区别这没有错呀,晕