Showing posts with label regarding. Show all posts
Showing posts with label regarding. Show all posts

Sunday, February 26, 2012

ELSEIF in Stored Procedures?

I have found some documentation regarding the use of IF...ELSE statements in stored procedures, but what about multiple condition statements? For example, say I need 3 unique fields in my table. If my application passes a value that is a duplicate in one of the columns, the stored proc will fail, but it is difficult to know which item caused the failure and therefore difficult for the user to get a meaningful error message in order to correct their input. I am thinking I could just make a conditional statement that applies a code to an OUTPUT parameter in order to clarify the error:

(pseudo code)

if @.field1 already exists then @.output = '1';terminate stored procedure

elseif @.field2 already exists then @.output = '2';terminate stored procedure

elseif @.field3 already exists then @.output = '3';terminate stored procedure

else finish the insert

(end pseudo code)

Are 'elseif' statements allowed in SQL Server? Am I going about this in the wrong way?

Jungalist wrote:

Are 'elseif' statements allowed in SQL Server?

Sort of. You can impletemt the logic as follows :

IF @.field1 already exists

BEGIN

SET @.OUTPUT = 1

END

ELSE

IF @.field2 already exists

BEGIN

SET @.OUTPUT=2

END

ELSE

IF @.field3 already exists

BEGIN

SET @.OUTPUT=3

END

check out books on line for "IF ELSE"

|||

Thank-you. I was searching for the wrong terms. I appreciate the help.

Friday, February 17, 2012

Effective Permissions for QA and EM

I am looking for information regarding permissions needed to be able to run
1) the Query Analyzer and 2) Enterprise Manager.
Since we are required to revoke all access from the public role, all
inherited permissions needed to run the above applications are gone. I
can't seem to find any documentation on which objects are needed in order to
make those functional for a particular role.
Thanks in advance,
AllenHi,
To open a database in Enterprise manager or Query Analyzer you should be
user in that partcular database. Then to access the object
you should have minimum select rights on table and exec rights on procedures
Thanks
Hari
"A McGuire" <allen.mcguire@.gmail.com.invalid> wrote in message
news:uCpzs$v5GHA.4304@.TK2MSFTNGP03.phx.gbl...
>I am looking for information regarding permissions needed to be able to run
>1) the Query Analyzer and 2) Enterprise Manager.
> Since we are required to revoke all access from the public role, all
> inherited permissions needed to run the above applications are gone. I
> can't seem to find any documentation on which objects are needed in order
> to make those functional for a particular role.
> Thanks in advance,
> Allen
>|||Thanks for your reply.
I understand you have to be a user in that database, but since I revoke all
access from public, simply adding a user to a database has a net result of
nothing. I need to know /specifically/ which objects the user would need
explicit access to.
Examples include:
- system tables in master
- sprocs and extended sprocs in master
- views in master (syslogins? sysconstraints?)
- system tables in user databases they need access to
etc...
I can take care of all the user objects - I need to know about system
objects. I can't just assign people to the db_owner database role either -
I need to grant them just enough privileges to use those two applications,
but no more.
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:uh8vHs15GHA.4112@.TK2MSFTNGP04.phx.gbl...
> Hi,
> To open a database in Enterprise manager or Query Analyzer you should be
> user in that partcular database. Then to access the object
> you should have minimum select rights on table and exec rights on
> procedures
> Thanks
> Hari
>
> "A McGuire" <allen.mcguire@.gmail.com.invalid> wrote in message
> news:uCpzs$v5GHA.4304@.TK2MSFTNGP03.phx.gbl...
>