首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请高手帮忙看下语法哪出错了。多谢

2012-04-14 
请高手帮忙看下语法哪出错了。。。谢谢createprocedurep_getsampledetailid@clientletterchar(1),@clientauto

请高手帮忙看下语法哪出错了。。。谢谢
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+ '-% '

热点排行