Re: Please Help
From: Sue Hoegemeier (Sue_H@nomail.please)
Date: 01/14/03
- Next message: oj: "Re: Please Help"
- Previous message: Dan Guzman: "Re: Application roles Please Help!"
- In reply to: David Lucus: "Re: Please Help"
- Next in thread: oj: "Re: Please Help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: Sue Hoegemeier <Sue_H@nomail.please> Date: Mon, 13 Jan 2003 20:55:17 -0700
I think if you use USE in a stored procedure, you need to
execute the entire statement dynamically with an EXEC - e.g.
EXEC('USE <SomeDatabase> EXEC sp_grantdbaccess...')
But....If I create a stored procedure in Northwinds that
executes:
exec pubs.dbo.sp_grantdbaccess @SomeUser
it works fine and creates the user in pubs when executed
from Northwinds. Could you post the specific error you get
when you try the same thing?
-Sue
On Mon, 13 Jan 2003 16:07:25 -0600, "David Lucus"
<davidl@studentlife.tamu.edu> wrote:
>It is now giving me another error. It is telling me that I cannot use the
>"USE" command in a procedure or trigger. This is in a stored procedure. if
>you have any other ideas I would be much appreciative.
>
>thx,
>David
>
>"Aaron Bertrand [MVP]" <aaron@TRASHaspfaq.com> wrote in message
>news:OyzSx10uCHA.1848@TK2MSFTNGP09...
>> Try issuing a USE command before executing, and not specifying the
>database
>> name in the EXEC call, like so:
>>
>> USE MASTER
>> EXEC sp_addlogin @newname
>>
>> USE DBName
>> EXEC sp_grantdbaccess @newname
>> EXEC sp_addrolemember @sturolename, @newname
>>
>> --
>> Aaron Bertrand, SQL Server MVP
>> http://www.aspfaq.com/
>>
>> Please reply in the newsgroups, but if you absolutely
>> must reply via e-mail, please take out the TRASH.
>>
>>
>> "David Lucus" <davidl@studentlife.tamu.edu> wrote in message
>> news:etA5uu0uCHA.2512@TK2MSFTNGP11...
>> > I have a stored procedure that adds new sql server accounts from the
>web.
>> > there are 2 databases that need teh login. The database where the
>stored
>> > procedure resides has no problems granting roles and db access
>> permissions,
>> > however when i try to give it permissions to the other database nothing
>is
>> > happening. It is not adding a user to the roles or throwing an error.
>> here
>> > is the code i am using to add the user to the second db
>> >
>> > EXECUTE DBName.dbo.sp_grantdbaccess @newname
>> >
>> > EXECUTE DBName.dbo.sp_addrolemember @sturolename, @newname
>> >
>> > where @newname is the variable with the name, and @sturolename is the
>role
>> > name.
>> >
>> > if anyone has any ideas please help.
>> >
>> > thx,
>> > David
>> >
>> >
>>
>>
>
- Next message: oj: "Re: Please Help"
- Previous message: Dan Guzman: "Re: Application roles Please Help!"
- In reply to: David Lucus: "Re: Please Help"
- Next in thread: oj: "Re: Please Help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|