Solved

how to create Windows user using t-sql

Posted on 2006-10-20
6
274 Views
Last Modified: 2008-03-03
hello, using T-SQL, how do i create Windows user  with Administrator rights ?
0
Comment
Question by:dynamicrevolutions
6 Comments
 
LVL 9

Expert Comment

by:dduser
ID: 17772044
Check out sp_addlogin login in BOL

Regards,

dduser
0
 
LVL 9

Expert Comment

by:dduser
ID: 17772047
Also check sp_grantdbaccess in BOL

Regards,

dduser
0
 
LVL 9

Assisted Solution

by:dduser
dduser earned 125 total points
ID: 17772050
Sorry for the above check out sp_grantlogin, this would achieve what you want.

Regards,

dduser
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 29

Assisted Solution

by:Gautham Janardhan
Gautham Janardhan earned 125 total points
ID: 17772390


This example below allows the Windows NT user Corporate\BobJ to connect to SQL Server.

EXEC sp_grantlogin 'Corporate\BobJ'


Although a login can connect to SQL Server after sp_grantlogin has been executed, access to user databases is denied until a user account for the login is created in each database that the login must access. Use sp_grantdbaccess to create a user account in each user database.

Only members of the sysadmin or securityadmin fixed server roles can execute sp_grantlogin.

also check

Use
sp_addsrvrolemember [ @loginame = ] 'login'
    , [ @rolename = ] 'role'


0
 
LVL 42

Assisted Solution

by:EugeneZ
EugeneZ earned 125 total points
ID: 17772582


IF you meant to add windows login to sql server logins with sql server sa rights...


USE [master]
GO
EXEC master.dbo.sp_grantlogin @loginame = N'yourdomain\userlogin'
EXEC master.dbo.sp_defaultdb @loginame = N'yourdomain\userlogin', @defdb = N'master'
EXEC master.dbo.sp_defaultlanguage @loginame = N'yourdomain\userlogin'
GO
EXEC master..sp_addsrvrolemember @loginame = N'yourdomain\userlogin', @rolename = N'sysadmin'
GO
0
 
LVL 29

Accepted Solution

by:
Nightman earned 125 total points
ID: 17779209
And if you mean 'How do I create a Windows Domain user and make an administrator on the Domain using T-SQL' the answer is you can't.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now