Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create user stored procedure using username as schema

Status
Not open for further replies.

daveonion

Programmer
Aug 21, 2002
359
GB
Hi

I know this is a security problem but i am unsure which access i need to give the account, basically im running the stored procedure as below,
exec('CREATE USER ' + '[' + @Login +']' + ' FOR LOGIN [' + @Login + '] WITH DEFAULT_SCHEMA=[dbo]'),

however when a user runs it it will create the user account however it doesn't use the default schema as dbo instead it uses the login name.
It runs fine if i do it so im guessing theres a permission im missing on the dbo schema for the user.
any help would be appreciated.
 
dbo is short for database owner, giving users access to this schema allows then to do just about anything to your database...

--------------------
Procrastinate Now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top