Solved

how to create Windows user using t-sql

Posted on 2006-10-20
6
279 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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 43

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

738 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