MS SQL Server
  Home arrow MS SQL Server arrow Page 3 - Configuring SQL Server Express 2005
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

Configuring SQL Server Express 2005
By: Justin Cook
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 45
    2004-09-09

    Table of Contents:
  • Configuring SQL Server Express 2005
  • The Easy Part – Installation
  • The Not-So-Easy Part – Configuration
  • Next – Connecting to Your Application
  • The Connection String

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Configuring SQL Server Express 2005 - The Not-So-Easy Part – Configuration


    (Page 3 of 5 )

    No doubt you strive for maximum security (the maximum possible within Windows that is) on your home PC. One of the most basic rules to follow in that case is not do your regular computing tasks as Administrator. Have an administrator account for installing applications, but then run as a regular 'user' for all other tasks, including programming.

    The unfortunate result of taking that precaution, is that as a user you won't be able to login to SQL Express, only the administrator will. So we need to change that. But how do we do such a thing without a GUI admin tool? Simple, we go back to the old command prompt!

    To do this I need to clarify two things.

    1. The SQL server name until this point has remained a mystery. Microsoft has decided that we have no need of changing the name, so it is preset as [MachineName]\SQLExpress. You can use 'localhost', '(local)', or even a period in place of your machine name, but I recommend specifying your machine name at lease in you application configuration files, so that you can easily spot where and what to change if you move SQL to another box, unlikely though that is.

    2. Though there is no GUI tools, Microsoft has not left us entirely up the creek. They provided a command line tool, called 'SQLCMD'.

    So, fire up your command prompt (as administrator) and type in:

    SQLCMD.exe -S (local)\SQLExpress -E

    So now we are interacting with SQL Server Express, which as mentioned runs as 'SQLExpress' on the local machine.

    To actually add a user, we're going to use the SQL Server System Security Stored Procedures. For now, these are the only options we have for administering security. The one we want right now is 'sp_grantlogin'. This will allow us or others to login to SQL server from non-administrator accounts. Type in:

    > EXEC sp_grantlogin '[machineName]\[userName]'
    > GO

    Obviously you're substituting your machine and user name in there. Just thought I'd clarify that. Now we can add the user to SQL with another stored procedure: 'sp_adduser'. Type in:

    > EXEC sp_adduser '[machineName]\[userName]', '[userNameInDB]'
    > GO

    It's good to specify the second parameter, the 'userNameInDB', so that you don't have to type in their full machine and user name every time. For instance, you could use 'Joe', and reference that user by 'Joe' in the other stored procedures that will come up.

    You now want to make yourself a sysadmin, so that you can login to SQL Server from your user account and still have full abilities within the system. For that we will use the stored procedure 'sp_addsrvrolemember'. Type in:

    > EXEC sp_ addsrvrolemember '[userName]', 'sysadmin'
    > GO

    And there you have it, you will now be able to log in and administer databases from the 'Database Explorer' within the express tools. Use these tools to create a new database. Remember the name of the database, as you'll need it for the next part! You can do this very easily by right-clicking on Data Connections, then click 'Create new SQL Server database...', and follow the wizard.

    More MS SQL Server Articles
    More By Justin Cook


       · I just wanted to leave you my compliments and thanks for the great article. I had...
       · 
       · ----------------------------------------Get free email at...
       · At the second step when I enter the command for EXEC sp_grantlogin...
       · Many thanks - I found your article very helpful. Just one thing. I believe that the...
       · Same problem I am having.
       · Can you register SQL 2005 Express server with SQL Enterprise Manager (GUI tool to...
       · What is going to happen when the app is published to a website on a server operated...
       · I came across the same error when I tried using MachineName/UserNameWhat I tried...
       · Thanks for the amazing tutorial. Got me up and running with no errors in 5 minutes!...
       · tnx, it has been very helpfull
       · Hi this article looks very relevant however before i start i would be grateful...
     

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT