Love SQL 2008 Express RTM but no tools yet…


When you download SQL 2008 Express, the version available currently does not have tools like SQL Management Studio.  The tools will be available soon but if you are like me and cannot wait for the tools to become available, you can use Visual Studio 2008 to perform a lot of tasks.  Visual Studio 2008 Server Explorer allows you to connect to SQL Server 2008 Express RTM and attach databases, view objects, etc.


However, let's say you need to grant access to a database to an account so that your web application can use SQL Server 2008 Express.  The account that would need access to SQL Express is the account configured for the worker process in IIS.  Here are steps to grant read/write access to a database to a user in SQL Server 2008 Express using the command-line interface:


First, connect to SQL 2008 Express using SqlCmd by opening an command prompt (admin command prompt for Vista) and typing this command:  (assumes you went with the default named instance)


SqlCmd -S .\SQLExpress


Type this command to create a database user and then hit Enter:


CREATE LOGIN [machinename\useraccount] FROM WINDOWS


Type GO and then hit Enter.


Type this command to switch to the desired database and then hit Enter:


USE Databasename


Type GO and then hit Enter.


Type this command to add the login as a user in the database and then hit Enter:


CREATE USER dbusername FOR LOGIN [machinename\username]


Type GO and then hit Enter.


Type this command to add the username to the reader/writer role in the database and then hit Enter:


sp_addrolemember 'db_datawriter','dbusername'


Here is a screen shot of the command-window running these commands:


image


You could type GO once at the end to execute all of the commands as a batch but I went one at a time to make sure I had each command correct.

Comments (3)
  1. You’ve been kicked (a good thing) – Trackback from DotNetKicks.com

  2. int19h says:

    > The tools will be available soon

    The only question is, how soon is "soon"…

Comments are closed.

Skip to main content