Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / SQLEXPRESS

Enabling SQL Express User

2.83/5 (3 votes)
23 Aug 2017CPOL1 min read 12.4K  
How to enable SQL Express user

Visual Studio(VS) lovers! Yes, we want to work on everything from within the VS. Yes, of course, our VS have required features to support us to perform various development and ALM operations. Database is one of the main parts of any application development. Instead of working on the database objects using SQL Server Management Studio, we prefer to use VS. Access the database directly from VS using the SQL Server Object Explorer. Moreover, we would like to work with the SQL express instead of connecting to a centralized database server for small project or at the starting of a project.

Even though we have Admin access, most of the time, we end up with permission issues in database level. This prevents us from create a database in SQL Express.

If you have Admin privilege in system, we can quickly fix this issue. Go to your services using Start> Run> services.msc. Locate the SQL Server (SQLEXPRESS) service from the list of services.

Right click and select Properties.

Image 1

Stop the service using the Stop option in the Properties window, if not stopped. Now, enter -m into the Start parameters text box to start the SQL express service in Single used mode.

Image 2

Start the service using Start option in the Properties window.

Go to command prompt using Start>Run>cmd and run the following commands to add the domain user as a sysadmin to SQL express.

Note: Replace domain\user with the corresponding domain user information before running the following command.

osql -S .\sqlexpress -E
create login [domain\user] from windows
go
exec sp_addsrvrolemember @loginame= ‘domain\user’, @rolename='sysadmin'
go

Once the command execution completes, navigate back to the services window and stop the SQL Express service. Remove -m from Start parameters and start the SQL express service to support multiple users.

Now, we can create a new database using Visual Studio’s SQL Server Object Explorer and perform our database operations.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)