明白了,刚才查了一下帮助要这样写
alter proc hkw
@com_id   char(10)   =null,
@com_name char(100)=null
AS
if @com_name is null  
select total=sum(salary) from works where company_id=@com_id 
else
begin
SELECT @com_name = '%'+RTRIM(@com_name) + '%'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`要这样写!
select total=sum(a.salary) from works a,company b where b.company_name like @com_name and a.company_id=b.company_id
order by total desc
end
go
exec hkw '','banka'
go