Re: Please Help

From: David Lucus (davidl@studentlife.tamu.edu)
Date: 01/13/03


From: "David Lucus" <davidl@studentlife.tamu.edu>
Date: Mon, 13 Jan 2003 16:07:25 -0600


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
> >
> >
>
>



Relevant Pages

  • Re: Please Help
    ... Try issuing a USE command before executing, and not specifying the database ... EXEC sp_addlogin @newname ... EXEC sp_grantdbaccess @newname ...
    (microsoft.public.sqlserver.security)
  • Get Table and Field Names
    ... To get a list of available tables in current database, ... execute the following command: ... EXEC sp_msforeachtable @command1='print REPLACE(REPLACE ... properties for a table, execute the ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: ALTER TABLE statement to lengthen column
    ... check the compatibility level of the database. ... exec sp_dbcmptlevel ... If not 7 then run following command. ... Vishal Parkar ...
    (microsoft.public.sqlserver.server)
  • RE: Event ID 447
    ... Please made a backup for Exchange database first. ... Please run the eseutil /mh command to see if the mailbox store is clean ... Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.windows.server.sbs)
  • Re: Sharepoint Database falling over event 1000
    ... Microsoft Small Business Server Support ... > I Have Just run the SQL command from the command Line, ... > affected)1> exitDoes this say the database is Ok?If so why since we loaded ... > I/O operation has been aborted because ofeither a thread exit or an ...
    (microsoft.public.windows.server.sbs)