Pass multiple INT in stored procedure


I have taken over ownership of a SQL database with a number of Stored Procedures and i'm trying to work out how some of them work.  One of the SP has the following:

IF @Options & 1 = 1 EXEC Action_All @CompanyID
IF @Options & 2 = 2 EXEC FlowAll @CompanyD, @UserID, ''
IF @Options & 1 = 1 AND @Options & 2 = 2

Open in new window

When I execute the SP in the Management Studio I have 4 fields available one is the @Options.  

If I enter 1, the SP executes.  If I enter 2, the SP executes.  However I need to pass 1 & 2.  How do I do this?  I have tried passing:

1 & 2

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongSoftware Team Lead, ex-Business Systems Analyst , ex-Senior Application EngineerCommented:
you got to pass 2 parameters here or else if still keep with one parameter, you need to compare with string value of '1,2', not '1' and '2'
Scott PletcherSenior DBACommented:
Pass 3 (1 + 2).

The & allows the code to check for individual bits to see if they are on.
The bit values, which you can set independently of each other, are:
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 etc. (keep multiplying by 2 until the number gets too large to fit).

For example, to set bits 1 2 8 and 64, you'd specify:
@options = 75

Though I often prefer to make it clear what is going on by doing this:

DECLARE @options int
SET @options = 1 + 2

EXEC dbo.proc_name @options = @options

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
anthonytrAuthor Commented:
Thanks for the super clear response!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Stored Proc

From novice to tech pro — start learning today.