HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How do you connect to SQL Server 2008 Express when SA is disabled?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
expressconnect2008yousqldisabledhowserverwhen

Problem

I'm trying to create a database in SQL Server 2008 Express (as installed by Visual Studio) but I don't seem to have any permissions to do so. There must be a way to do this, or there would be no point in VS.NET installing it.

Internet articles suggest adding my domain login to the sysadmin role but I'm failing at the first hurdle:

C:\>sqlcmd -S .\sqlexpress
Sqlcmd: '-S': Unknown Option. Enter '-?' for help.


OK... so I then run with "-?" to get help and it says:

C:\>sqlcmd -?
Microsoft (R) SQL Server Command Line Tool
Version 10.0.5500.0 NT x64

usage: Sqlcmd            [-U login id]          [-P password]
  [-S server]            [-H hostname]          [-E trusted connection]
  [-d use database name] [-l login timeout]     [-t query timeout]


Notice how -S is a valid option! I don't understand why the help text doesn't seem to match up with the error text. Is -S an option or not? And if not, what is the command line to specify the server name?

Solution

you could start SQL Server in single-user mode.

When you do that, any windows administator can connect to SQL Server as a SQL Server administrator. Then you can re-create the sa user

Context

StackExchange Database Administrators Q#23410, answer score: 3

Revisions (0)

No revisions yet.