请高手帮忙看下语法哪出错了。。。谢谢
create procedure p_getsampledetailid
@clientletter char(1),
@clientautono int,
@styleno varchar(28),
@sampleid int output,
@detailid int output
as
(
select @sampleid=max(sampleapplicationid) from sampleapplication where active <2 and clientletter=@clientletter and clientautono=@clientautono and styleno=@styleno
if @sampleid is null
begin
select @sampleid=max(sampleapplicationid) from sampleapplication where active <2
if @sampleid is null
select @sampleid= 15000
end
select @detailid=count(sampleapplicationdetailid)+1 from sampleapplicationdetail where sampleapplicationdetailid like @sampleid+ '-% '
)
[解决办法]
create procedure p_getsampledetailid
@clientletter char(1),
@clientautono int,
@styleno varchar(28),
@sampleid int output,
@detailid int output
as
begin
select
@sampleid=max(sampleapplicationid)
from
sampleapplication
where
active <2
and
clientletter=@clientletter
and
clientautono=@clientautono
and
styleno=@styleno
if @sampleid is null
begin
select @sampleid=max(sampleapplicationid) from sampleapplication where active <2
if @sampleid is null
set @sampleid=15000
end
select
@detailid=count(sampleapplicationdetailid)+1
from
sampleapplicationdetail
where
sampleapplicationdetailid like @sampleid+ '-% '
return
end
go
[解决办法]
楼主把两个括号去掉不就得了:)
create procedure p_getsampledetailid
@clientletter char(1),
@clientautono int,
@styleno varchar(28),
@sampleid int output,
@detailid int output
as
select @sampleid=max(sampleapplicationid) from sampleapplication where active <2 and clientletter=@clientletter and clientautono=@clientautono and styleno=@styleno
if @sampleid is null
begin
select @sampleid=max(sampleapplicationid) from sampleapplication where active <2
if @sampleid is null
select @sampleid= 15000
end
select @detailid=count(sampleapplicationdetailid)+1 from sampleapplicationdetail where sampleapplicationdetailid like @sampleid+ '-% '