当前位置: 代码迷 >> Sql Server >> 请高手帮忙看下语法哪出错了。多谢
  详细解决方案

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

热度:7   发布时间:2016-04-27 16:48:31.0
请高手帮忙看下语法哪出错了。。。谢谢
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   [email protected]   and   [email protected]   and   [email protected]
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
[email protected]
and
[email protected]
and
[email protected]

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 [email protected] and [email protected] and [email protected]
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+ '-% '
  相关解决方案