原题:
http://community.csdn.net/Expert/topic/5243/5243103.xml?temp=.7722895
可能是我表达不清楚吧。答案并不是我想要的。 if @x>= ( select 其它1 from excel_sql where 卡号=@stud_ID and 姓名=@stud_name )
begin
select @sql= @sql + ' ,其它费1=其它1 '
set @x=( select 其它1 from excel_sql where 卡号=@stud_ID and 姓名=@stud_name ) --想办法在判断的同时给变量赋值,不然这句是第二次运行了。???
end
else
begin
select @sql= @sql + ',其它费1='+rtrim(@x)
end
http://community.csdn.net/Expert/topic/5243/5243103.xml?temp=.7722895
可能是我表达不清楚吧。答案并不是我想要的。 if @x>= ( select 其它1 from excel_sql where 卡号=@stud_ID and 姓名=@stud_name )
begin
select @sql= @sql + ' ,其它费1=其它1 '
set @x=( select 其它1 from excel_sql where 卡号=@stud_ID and 姓名=@stud_name ) --想办法在判断的同时给变量赋值,不然这句是第二次运行了。???
end
else
begin
select @sql= @sql + ',其它费1='+rtrim(@x)
end
ALTER PROCEDURE cp_edit_StudInfo_bank2
@stud_name nvarchar(20),--客户名称
@stud_ID nvarchar(20),--客户帐号
@stud_meoney int, --[应收/付金额]
@stud_meoney1 int --[实际发生额]
...
...
...
declare @sql varchar(1000),
@x int select @x=select 其它2 from excel_sql where 卡号=@stud_ID and 姓名=@stud_name
if @stud_meoney1>=@x
begin
select @sql= @sql + ' ,其它费2=其它2 '
end
else
begin
select @sql= @sql + ' ,其它费2= '+@x
end
::::
if @x>= ( select 其它1 from excel_sql where 卡号=@stud_ID and 姓名=@stud_name )
begin
select @sql= @sql + ' ,其它费1=其它1 '
set @x=( select 其它1 from excel_sql where 卡号=@stud_ID and 姓名=@stud_name ) --想办法在判断的同时给变量赋值,不然这句是第二次运行了。???
end
else
begin
select @sql= @sql + ',其它费1='+rtrim(@x)
end
--------------已经不是用@stud_meoney1 来判断了。
declare @x1 ...
set @x1=( select 其它1 from excel_sql where 卡号=@stud_ID and 姓名=@stud_name )
if @x>= @x1
begin
select @sql= @sql + ' ,其它费1=其它1 '
set @x=@x1
end
else
begin
select @sql= @sql + ',其它费1='+rtrim(@x)
end
begin
select @sql= @sql + ' ,其它费1=其它1 '
set @x=( select 其它1 from excel_sql where 卡号=@stud_ID and 姓名=@stud_name )
end
else
begin
select @sql= @sql + ',其它费1='+rtrim(@x)
end
因為 exists 是返回 true or false