Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 150
  • Last Modified:

creating new user in SQL server

hi

How can i create a new user in sql server than change the user to this new user so that the new database i create is owned by the new user i created.

Mahesh
0
princemahesh
Asked:
princemahesh
1 Solution
 
ziolkoCommented:
You want to do this from Delphi code? or with SQLServer's Enterprise Manager?
ziolko.
0
 
geobulCommented:
Hi,

It depends on the SQL server you are using. If you are talking about MS SQL Server, there are system stored procedures you may use: sp_addgroup, sp_adduser, sp_password. Use GRANT statement to set the necessary permissions to that user.
After adding a new user successfully you have to disconnect and connect as the newly created user. Then execute your CREATE DATABASE and CREATE TABLE statements.

You could also create the database as the first user, add a new user (using SP's above) and then execute sp_changedbowner system stored procedure at the end in order to make the newly created user the owner of that database.

Regards, Geo
0
 
CleanupPingCommented:
princemahesh:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
princemaheshAuthor Commented:
sorry ziolko I was away thats why i could not check the comments.....

I want to change it from delphi.....

Prince
0
 
geobulCommented:
That's what I explained - from Delphi using ADOStoredProc, ADOQuery, ADOCommand components.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now