Solved

how to create Windows user using t-sql

Posted on 2006-10-20
6
278 Views
Last Modified: 2008-03-03
hello, using T-SQL, how do i create Windows user  with Administrator rights ?
0
Comment
Question by:dynamicrevolutions
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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:Eugene Z
Eugene Z 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

740 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