Link to home
Start Free TrialLog in
Avatar of cheryl9063
cheryl9063Flag for United States of America

asked on

t-sql

declare @ReqStatusDE int

if @ReqStatusDE in (select id from Requisition_Status_DE rsde where EntryCode in ('LockWait', 'Locked', 'Trans', 'LocNevTran'))


The select statement returns 5 rows.. What error will the above syntax give you?
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

>What error will the above syntax give you?
Likely 'Can't find table Requisition_Status_DE', as I don't have access to your data source.

What's your question?

Maybe...

declare @ReqStatusDE int

SELECT @ReqStatusDE = 42  -- or something

IF EXISTS (
   select id
   from Requisition_Status_DE rsde
   where EntryCode in ('LockWait', 'Locked', 'Trans', 'LocNevTran')
      and id = ReqStatusDE )
 
  begin
   -do whatever if it exists
  end
Avatar of cheryl9063

ASKER

Would it give you the error

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. ?
A vendor did this and we are getting that error.. I think this is the part of the code that needs to be changed..
SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it wont throw any error because of the 'IN', if it was an '=' it would have.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial