我觉得用存储过程比较好,假设A为主键create proc pname @pri int --@pri这个参数是表的主键--类型与表的主键类型一致asselect * into temp from table_name where A=@prideclare @count intset @count=1select @count=@count+1 from temp where B is not nullselect @count=@count+1 from temp where C is not null... ...print '完成百分比为:'+left(convert(varchar(10),round(@line/3.0*100,1)),4)+'%'drop table temp --如果不把临时表删除,在再次执行该存储过程的时候会报错go说明一下:set @count=1,是把主键算上,因为主键不能空。也就是说,表中有几列不能为空,@count 的初使值就为几。print中的几个函数:left(),有两个参数:从第一个参数中取第二个参数个字符,也就是说第一个参数为字符型,第二个为整数。convert()是将数转换为字符型数据round()有两个参数,取近似值,第二个参数为小数点的位数,第一个参数为要求的数。 效率问题我是想不出好的了。我觉得这样也挺快的。