Solved

Adding Logon to SQL Express Database

Posted on 2012-04-06
3
334 Views
Last Modified: 2012-04-11
Hello,

I have an application that automatically loads SQL Express 2008 onto my workstation, and it uses the user account that is logged in for the administrator. So, this user has a login with the account from the domain server.

The workstation is Windows 7.

I logged into this workstation with a different account. Now, I cannot access the database because my accong is not an authorized login. I can use the local SA account, but I don't want to do that. Instead, I want to add my domain account to the Logins. When I try to add my domain account, the Management Studio cannot find my account. Also, it only lists my local machine as the location to search. It does not allow me to search through the domain for existing accounts. Why doesn't it allow me to search through the domain and add a domain account? can I change this, and how do I change this so that I can add a domain account to this database?

Thanks,
John
0
Comment
Question by:jhieb
[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
3 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 37818910
I have used this in the past to give access but you need to do it logged in as an administrator or do it from an admin sql prompt (sqlcmd -A):

CREATE LOGIN [<domainName>\<loginName>] FROM WINDOWS;
GO
0
 
LVL 42

Expert Comment

by:Eugene Z
ID: 37821194
<When I try to add my domain account, the Management Studio cannot find my account. Also, it only lists my local machine as the location to search>
looks like your workstation  is not part of AD (probably Workgroup member).. check it
you can add local account  workstation\newlogin

try above code to add
and additionaly

USE [master]
GO
CREATE LOGIN [yourDomainname\user] FROM WINDOWS WITH DEFAULT_DATABASE=[master] ---< as above
GO
EXEC master..sp_addsrvrolemember @loginame = N'yourDomainname\user', @rolename = N'sysadmin'
GO
0
 
LVL 1

Author Closing Comment

by:jhieb
ID: 37824266
This did it and it was easy to do. I wonder why the domain did not show up even though this machine is a domain member. Thanks for the help. I can now access my database.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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.
I have a large data set and a SSIS package. How can I load this file in multi threading?
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

749 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