However, when I went to re-attach, it said my login was no longer good. I
assume this is because my login had that database as the default database.
Now, when I look in the list of logins, that user is no longer there. The
only logins listed now are the one I name in the connection string (for the
web site to function) and sa. When I login as the web user, I cannot add a
new login, change any default databases, or change my sa password. When I
try to login as sa, I have forgotten the password.
At this point, I am stumped. What can I do? Can I change the sa password
somehow (to something I can remember) to re-add my windows username? Any
other ideas?
http://msdn.microsoft.com/en-us/library/ms174428.aspx
--
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
Maybe I'm reading it wrong, but that only works when you know the password.
I have forgotten it.
This assumes you can connect to SQL Server as someone in the sysadmin role;
if you can do that, you don't need to know the sa password.
Have you seen any error messages that lead you to believe the inability to
connect with your previous credentials is because your default db no longer
exists.?
If your login is a member of the sysadmin role (which I'm guessing it is
because you can detach, and were planning to attach a db), you can use the
command line interface sqlcmd. From a command prompt, you can specify the
database to use:
C:\sqlcmd -E -d master
Once you are connected, you can run the sp_password command to reset the sa
password, or the ALTER LOGIN command to reset your default database.
Check Books Online for full syntax, and feel free to ask for more help if
get stuck.
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:u6at2j6Y...@TK2MSFTNGP06.phx.gbl...
SP_PASSWORD @NEW = 'my_password', @loginame = 'sa'
--
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
Dang, this sucks!
Dave Patrick wrote:
> Try;
>
> SP_PASSWORD @NEW = 'my_password', @loginame = 'sa'
>
>
>
>
I'm James. Patrick is the guy who was tryong to help me in theprevious post.
> This assumes you can connect to SQL Server as someone in the sysadmin
> role; if you can do that, you don't need to know the sa password.
I cannot connct as anyone except the asp user, which doesn't have much in
the way of permissions.
> Have you seen any error messages that lead you to believe the
> inability to connect with your previous credentials is because your
> default db no longer exists.?
>
No. I assumed that was the case because once I detached it, I couldn't
connect any more.
> If your login is a member of the sysadmin role (which I'm guessing it
> is because you can detach, and were planning to attach a db), you can
> use the command line interface sqlcmd. From a command prompt, you can
> specify the database to use:
>
> C:\sqlcmd -E -d master
>
> Once you are connected, you can run the sp_password command to reset
> the sa password, or the ALTER LOGIN command to reset your default
> database.
Using the command prompt, I jist tried it. The first part:
> C:\sqlcmd -E -d master
was successful. However, I then entered:
SP_PASSWORD @NEW = 'my_password', @loginame = 'sa'
and didn't see any errors, but tried to connect as sa with that password and
it gave me this error message:
Msg 15151, Level 16, State 1, Line 1
Cannot alter the login 'sa', because it does not exist or you do not have
permission.
This is unexpected, as you were able to get in to detach a db, so you must
have some privileges. The message you got:
> Cannot alter the login 'sa', because it does not exist or you do not have
> permission.
>
... is a response to the sp_password command. So when you say you tried to
reconnect with 'sa', can you tell us how you did that?
Also, when using the SQLCMD tool, you have to type GO to execute a command:
SP_PASSWORD @NEW = 'my_password', @loginame = 'sa'
GO
Then you need to exit before you try to reconnect.
Try getting in again, and seeing who you are. So after connecting:
C:\sqlcmd -E -d master
Please run this:
SELECT suser_sname(), user_name()
GO
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:OJ5g1$9YJHA...@TK2MSFTNGP03.phx.gbl...
Oh, no apology needed. I just didn't want Patrick to not get his due.
>
> This is unexpected, as you were able to get in to detach a db, so you
> must have some privileges. The message you got:
>> Cannot alter the login 'sa', because it does not exist or you do not
>> have permission.
>>
> ... is a response to the sp_password command. So when you say you
> tried to reconnect with 'sa', can you tell us how you did that?
When I did the detach, it was under my Windows username(james), which had (I
think) admin privileges.Once I did the detach, I tried to re-attach, and
then got the permissions error. At this point I was still logged is as my
Windows name. But because of the error, I closed Mgmt Studio, then re-opened
it and tried to connect using Windows authentication as james. It woudn't
let me. So I tried to login with the sa name and password, but I realized I
had forgotten it. I finally logged in using the asp name and password, using
SQL Server authentication. I coudn't forget that password, because it's in
the connection string of one of my old asp websites.
Once in, I looked in the list of logins, and the first one (my windows
username) was not listed anymore.
Eveyrthing I did after that in response to suggestions from you or Patrick
has been under the asp login.
>
> Also, when using the SQLCMD tool, you have to type GO to execute a
> command:
AHHH. Didn't know that.
>
> SP_PASSWORD @NEW = 'my_password', @loginame = 'sa'
> GO
>
> Then you need to exit before you try to reconnect.
>
>
> Try getting in again, and seeing who you are. So after connecting:
> C:\sqlcmd -E -d master
>
> Please run this:
>
> SELECT suser_sname(), user_name()
> GO
>
>
It returned (without quotes):
"HOME\James"
I should add that HOME is my machine name, so that makes sense.
SP_PASSWORD @NEW = 'my_password', @loginame = 'sa'
then I opened Mgmt studio, and tried to login with sa, and it said the sa
account is disabled.
If you do indeed have admin rights, you should be able to enable the sa
account with ALTER LOGIN. You can read the full syntax in Books Online but
it will be something like:
ALTER LOGIN sa ENABLE
GO
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:ee$dCFLZJ...@TK2MSFTNGP03.phx.gbl...
Note:
I know this is off the topic but it's a little bit weird that you use
Standard Edition of SQL Server for development purposes? Because Developer
Edition is made for this purpose and its license costs about 50$.
--
Ekrem Önsoy
"middletree" <middl...@verywarmmail.com> wrote in message
news:OLbm$AzYJH...@TK2MSFTNGP04.phx.gbl...
I didn't catch it before, but it says HOME\James dbo
> If you do indeed have admin rights, you should be able to enable the
> sa account with ALTER LOGIN. You can read the full syntax in Books
> Online but it will be something like:
>
> ALTER LOGIN sa ENABLE
> GO
Wow! It worked.
Thanks!!!!!!!
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:uwWIRvPZ...@TK2MSFTNGP03.phx.gbl...
You might be better off trying to the do the attach using TSQL syntax. Look
up CREATE DATABASE FOR ATTACH in the Books Online.
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:uKSYSzPZ...@TK2MSFTNGP05.phx.gbl...
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:em6ToxPZ...@TK2MSFTNGP03.phx.gbl...
Connect as sa and execute sp_helplogins and see what it says about James.
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:em6ToxPZ...@TK2MSFTNGP03.phx.gbl...
So thanks for your help. I have one follow-up question: is there any harm is
keeping master as my default database going forward?
Hi Middletree,
The only possible harm is if you run a script such as
CREATE DATABASE xxx .....
go
USE xxx
go
CREATE TABLE ...
(etc)
If the CREATE fails, the USE will fail as well, and the tables, stored
procedures, and other objects will be created in master. You'll have to
untangle the mess manually afterwards.
A better option is to set tempdb as your default database. If you end up
creating objects in tempdb, they'll automatically be gone the next time
you restart SQL Server. (The tempdb database is dropped and recreated on
restart of the service).
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
"Hugo Kornelis" <hu...@perFact.REMOVETHIS.info.INVALID> wrote in message
news:0vphl45hmjrb6bo5o...@4ax.com...
Dave Patrick wrote:
Re: lost sa password--am I hosed?
21-Dec-08
Give this a go.
http://msdn.microsoft.com/en-us/library/ms174428.aspx
--
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
"middletree" wrote:
Previous Posts In This Thread:
On Sunday, December 21, 2008 12:52 AM
middletree wrote:
lost sa password--am I hosed?
Using SQL Server 2005 Standard. I had been using my windows login name with
Windows authentication to log into a database on my home machine (Windows XP
Pro) which I use for development. I wanted ot make a copy of the database
that I use most often, and chose to do a detach, then make a copy in Windows
Explorer, then my plan was to re-attach the database.
However, when I went to re-attach, it said my login was no longer good. I
assume this is because my login had that database as the default database.
Now, when I look in the list of logins, that user is no longer there. The
only logins listed now are the one I name in the connection string (for the
web site to function) and sa. When I login as the web user, I cannot add a
new login, change any default databases, or change my sa password. When I
try to login as sa, I have forgotten the password.
At this point, I am stumped. What can I do? Can I change the sa password
somehow (to something I can remember) to re-add my windows username? Any
other ideas?
On Sunday, December 21, 2008 10:17 AM
Dave Patrick wrote:
Re: lost sa password--am I hosed?
Give this a go.
http://msdn.microsoft.com/en-us/library/ms174428.aspx
--
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
"middletree" wrote:
On Sunday, December 21, 2008 3:16 PM
middletree wrote:
Re: lost sa password--am I hosed?
Dave Patrick wrote:
Maybe I am reading it wrong, but that only works when you know the password.
I have forgotten it.
On Sunday, December 21, 2008 5:37 PM
Kalen Delaney wrote:
Hi PatrickThis assumes you can connect to SQL Server as someone in the
Hi Patrick
This assumes you can connect to SQL Server as someone in the sysadmin role;
if you can do that, you don't need to know the sa password.
Have you seen any error messages that lead you to believe the inability to
connect with your previous credentials is because your default db no longer
exists.?
If your login is a member of the sysadmin role (which I'm guessing it is
because you can detach, and were planning to attach a db), you can use the
command line interface sqlcmd. From a command prompt, you can specify the
database to use:
C:\sqlcmd -E -d master
Once you are connected, you can run the sp_password command to reset the sa
password, or the ALTER LOGIN command to reset your default database.
Check Books Online for full syntax, and feel free to ask for more help if
get stuck.
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:u6at2j6Y...@TK2MSFTNGP06.phx.gbl...
On Sunday, December 21, 2008 5:40 PM
Dave Patrick wrote:
Re: lost sa password--am I hosed?
Try;
SP_PASSWORD @NEW = 'my_password', @loginame = 'sa'
--
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
"middletree" wrote:
On Sunday, December 21, 2008 9:44 PM
middletree wrote:
Yeha, this would work if I could get in as a user with permissions. But since.
Yeha, this would work if I could get in as a user with permissions. But
since.I can only get into Management Server by logging in as the asp user, I
can't run that query.
Dang, this sucks!
Dave Patrick wrote:
On Sunday, December 21, 2008 9:49 PM
middletree wrote:
Re: lost sa password--am I hosed?
Kalen Delaney wrote:
I'm James. Patrick is the guy who was tryong to help me in theprevious post.
I cannot connct as anyone except the asp user, which doesn't have much in
the way of permissions.
No. I assumed that was the case because once I detached it, I couldn't
connect any more.
Using the command prompt, I jist tried it. The first part:
was successful. However, I then entered:
SP_PASSWORD @NEW = 'my_password', @loginame = 'sa'
and didn't see any errors, but tried to connect as sa with that password and
it gave me this error message:
Msg 15151, Level 16, State 1, Line 1
Cannot alter the login 'sa', because it does not exist or you do not have
permission.
On Monday, December 22, 2008 12:06 PM
Kalen Delaney wrote:
I'm sorry for messing up your name. I usually try to be careful with that...
I'm sorry for messing up your name. I usually try to be careful with that...
This is unexpected, as you were able to get in to detach a db, so you must
have some privileges. The message you got:
.... is a response to the sp_password command. So when you say you tried to
reconnect with 'sa', can you tell us how you did that?
Also, when using the SQLCMD tool, you have to type GO to execute a command:
SP_PASSWORD @NEW = 'my_password', @loginame = 'sa'
GO
Then you need to exit before you try to reconnect.
Try getting in again, and seeing who you are. So after connecting:
C:\sqlcmd -E -d master
Please run this:
SELECT suser_sname(), user_name()
GO
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:OJ5g1$9YJHA...@TK2MSFTNGP03.phx.gbl...
On Monday, December 22, 2008 10:47 PM
middletree wrote:
Re: lost sa password--am I hosed?
Kalen Delaney wrote:
Oh, no apology needed. I just didn't want Patrick to not get his due.
When I did the detach, it was under my Windows username(james), which had (I
think) admin privileges.Once I did the detach, I tried to re-attach, and
then got the permissions error. At this point I was still logged is as my
Windows name. But because of the error, I closed Mgmt Studio, then re-opened
it and tried to connect using Windows authentication as james. It woudn't
let me. So I tried to login with the sa name and password, but I realized I
had forgotten it. I finally logged in using the asp name and password, using
SQL Server authentication. I coudn't forget that password, because it's in
the connection string of one of my old asp websites.
Once in, I looked in the list of logins, and the first one (my windows
username) was not listed anymore.
Eveyrthing I did after that in response to suggestions from you or Patrick
has been under the asp login.
AHHH. Didn't know that.
It returned (without quotes):
"HOME\James"
I should add that HOME is my machine name, so that makes sense.
On Monday, December 22, 2008 11:12 PM
middletree wrote:
Ok, I did the above, and then ran Patrick's instructions from the command
Ok, I did the above, and then ran Patrick's instructions from the command
prompt:
SP_PASSWORD @NEW = 'my_password', @loginame = 'sa'
then I opened Mgmt studio, and tried to login with sa, and it said the sa
account is disabled.
On Tuesday, December 23, 2008 1:50 AM
Kalen Delaney wrote:
So it sounds like you're in with the same credentials as when you did the
So it sounds like you're in with the same credentials as when you did the
detach. What did the second value return? The SELECT statement I gave you
should have returned two values.
If you do indeed have admin rights, you should be able to enable the sa
account with ALTER LOGIN. You can read the full syntax in Books Online but
it will be something like:
ALTER LOGIN sa ENABLE
GO
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:ee$dCFLZJ...@TK2MSFTNGP03.phx.gbl...
On Tuesday, December 23, 2008 6:26 AM
ekre wrote:
By default, a Login is created for Local Administrators Windows Group as
By default, a Login is created for Local Administrators Windows Group as
BULITIN\Administrators and it's a member of the sysadmin fixed server role.
I think your Windows Account (james) is not a member of the Local Admins
group. Do you have a chance to log in to your Windows as an administrator
and then you'd be able to connect to your SQL Server instance using Windows
Authentication and you'd be logged in as a System Administrator so you'd be
able to enabled "sa" Login or do whatevery you want to do.
Note:
I know this is off the topic but it's a little bit weird that you use
Standard Edition of SQL Server for development purposes? Because Developer
Edition is made for this purpose and its license costs about 50$.
--
Ekrem ?nsoy
"middletree" <middl...@verywarmmail.com> wrote in message
news:OLbm$AzYJH...@TK2MSFTNGP04.phx.gbl...
On Tuesday, December 23, 2008 7:41 AM
middletree wrote:
Re: lost sa password--am I hosed?
Kalen Delaney wrote:
I did not catch it before, but it says HOME\James dbo
Wow! It worked.
Thanks!!!!!!!
On Tuesday, December 23, 2008 7:45 AM
middletree wrote:
Now that I can get in with sa, I can't seem to get the James username to work
Now that I can get in with sa, I cannot seem to get the James username to
work anymore. When I use Mgmt studio to connect with Windows authentication,
it simply says that the login failed.
On Tuesday, December 23, 2008 7:48 AM
middletree wrote:
And when I try to re-attach while logged in as sa, it fails.
And when I try to re-attach while logged in as sa, it fails.
On Tuesday, December 23, 2008 11:26 AM
Kalen Delaney wrote:
You may have to re-add the James login while using the sa login.
You may have to re-add the James login while using the sa login.
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
On Tuesday, December 23, 2008 11:27 AM
Kalen Delaney wrote:
Yes, that's what I wanted to see.
Yes, that's what I wanted to see. If you are dbo in master, then you have
sysadmin privileges, whatever your login name is.
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:uwWIRvPZ...@TK2MSFTNGP03.phx.gbl...
On Tuesday, December 23, 2008 11:29 AM
Kalen Delaney wrote:
What does 'failed' mean?
What does 'failed' mean? Please let us know exactly how you are trying to
attach, and what error messages do you get. If you are someone who can alter
the sa login, you have permission to attach a db. There must be some setting
that is not correct.
You might be better off trying to the do the attach using TSQL syntax. Look
up CREATE DATABASE FOR ATTACH in the Books Online.
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:uKSYSzPZ...@TK2MSFTNGP05.phx.gbl...
On Tuesday, December 23, 2008 11:32 AM
Kalen Delaney wrote:
Exactly what are you doing to try to connect as James?
Exactly what are you doing to try to connect as James? Are you certain you
are logged into the machine with that name?
Connect as sa and execute sp_helplogins and see what it says about James.
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com
"middletree" <middl...@verywarmmail.com> wrote in message
news:em6ToxPZ...@TK2MSFTNGP03.phx.gbl...
On Sunday, December 28, 2008 7:45 PM
middletree wrote:
I connected into Mgmt Server as sa, opened up the James user, which was still
I connected into Mgmt Server as sa, opened up the James user, which was
still there. I went to Properties, then saw how the "Default database" field
was empty, so I selected "master". I then was able to connect through Mgmt
server as james, and then I was able to re-attach the database that I had
detached.
So thanks for your help. I have one follow-up question: is there any harm is
keeping master as my default database going forward?
On Monday, December 29, 2008 6:44 PM
Rick Byham, \(MSFT\) wrote:
Re: lost sa password--am I hosed?
Also see the new Books Online topic Troubleshooting: Connecting to SQL
Server When System Administrators Are Locked Out
http://msdn.microsoft.com/en-us/library/dd207004.aspx
This is a SQL Server 2008 topic but someone recently told me it works on SQL
Server 2005 also.
--
Rick Byham (MSFT), SQL Server Books Online
This posting is provided "AS IS" with no warranties, and confers no rights.
"Hugo Kornelis" <hu...@perFact.REMOVETHIS.info.INVALID> wrote in message
news:0vphl45hmjrb6bo5o...@4ax.com...
Submitted via EggHeadCafe - Software Developer Portal of Choice
Dr. Dotnetsky's Cool .NET Tips and Tricks # 4
http://www.eggheadcafe.com/tutorials/aspnet/4c320cce-8d7d-4558-b146-89d4f30844a0/dr-dotnetskys-cool-net.aspx