Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Aug 30 '12 at 0:48

This question came from our site for professional and enthusiast programmers.

    
are you able to connect SQL Server? –  Kundan Singh Chouhan Aug 28 '12 at 15:54
    
I can connect in SSMS using Windows Auth, but I don't have permission to do anything via that interface so I was told to use the (elevated) command line. I can see the list of databases, but I can't add my own Windows Account as a sysadmin using the GUI, as I don't have permission –  Nick G Aug 28 '12 at 15:56
add comment

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
    
Yes, but without being able to use the command above to specify which server to connect to, that is presumably impossible? –  Nick G Aug 28 '12 at 16:31
    
humm..dont know what you mean! Ok, you have your SQL Server Express service running right? You have to stop it, change the stat up mode (you can do it on the sql server configuration manager), this post shows you how to do it: blog.sqlauthority.com/2009/02/10/… and start it again –  Diego Aug 28 '12 at 16:36
    
Don't worry - got it working using instructions elsewhere but essentially doing what you suggested :) Thanks. –  Nick G Aug 28 '12 at 16:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.