开发者

rectify Error in my Storred procedure

开发者 https://www.devze.com 2023-03-05 19:51 出处:网络
I am getti开发者_StackOverflow社区ng error near AS what is a problem in IF..? Create Procedure dbo.sp_Normal_Search

I am getti开发者_StackOverflow社区ng error near AS what is a problem in IF..?

Create Procedure dbo.sp_Normal_Search
(
@title as nvarchar(max),
@Description as nvarchar(max),
@Keywords as nvarchar(max),
@Chk_title as Bit,
@Chk_Description as Bit,
@Chk_Keywords as Bit,
@RD_AND as Bit,
@RD_OR as Bit



AS
if(@RD_AND = 1)
Begin
    if(@Chk_title = 1)
        Begin
        (Select title from server_des where title Like '%'+ @title+'%')
        End
END
GO
)

I am getting error near AS what is a problem in IF..?


parentheses in wrong place:

Create Procedure dbo.sp_Normal_Search 
( 
   @title as nvarchar(max), 
   @Description as nvarchar(max), 
   @Keywords as nvarchar(max), 
   @Chk_title as Bit, 
   @Chk_Description as Bit, 
   @Chk_Keywords as Bit, 
   @RD_AND as Bit, 
   @RD_OR as Bit 
) 
AS

if @RD_AND = 1 
Begin 
    if @Chk_title = 1 
        Begin 
            Select title from server_des where title Like '%'+ @title+'%' 
        End 
END 
GO 

What are you planing to return if @RD_AND != 1


You need to remove the brackets... after your stored proc. name...

Change it to something like:

Create Procedure dbo.sp_Normal_Search 
   @title as nvarchar(max), 
   @Description as nvarchar(max), 
   @Keywords as nvarchar(max), 
   @Chk_title as Bit, 
   @Chk_Description as Bit, 
   @Chk_Keywords as Bit, 
   @RD_AND as Bit, 
   @RD_OR as Bit 
AS

if @RD_AND = 1
Begin 
    if @Chk_title = 1
        Begin 
            Select title 
            from server_des 
            where title Like '%' + @title + '%'
        End 
END 
GO 
0

精彩评论

暂无评论...
验证码 换一张
取 消