locked
Errr Comming in TSQL RRS feed

  • Question

  • User-1509801897 posted

    Why I am geting foloowing error 

    Msg 102, Level 15, State 1, Procedure sp_SearchAllBooksOnName1, Line 4

    Incorrect syntax near '='.

     

    In following Query


    create  procedure sp_SearchAllBooksOnName1(@B_name1 varchar(100))
     as
     select b.B_id,b.B_name,b.B_Auther,i.IssueDate,i.DueDate,
    b.B_status=

    case
       when 1 then 'Book Available'
       when 2 then 'Book Issued'
      end
     from tblBook b left join  tblBooksIssued i
     on(b.B_id=i.B_id)
    where
     b.B_name like @B_name1
    go

    Saturday, June 11, 2011 7:22 AM

Answers

  • User-693248168 posted

    This would be the correct SP

    Sorry, try this query.

    create  procedure sp_SearchAllBooksOnName1(@B_name1 varchar(100))
    as
    select b.B_id,b.B_name,b.B_Auther,i.IssueDate,i.DueDate,
    case
    when b.B_status=1 then 'Book Available'
    when b.B_status=2 then 'Book Issued'
    end as B_status
    from tblBook b left join tblBooksIssued i
    on(b.B_id=i.B_id)
    where
    b.B_name like @B_name1
    go
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 11, 2011 7:26 AM