For most of my databases, I am content to use Windows Authentication for my database access. In a development or small shop environment, it's usually acceptable to let Windows bear the burden of authentication.
But if you need to add just one database app that requires a separate login beyond the Windows login, here's how.
First a few definitions.
SERVER vs. DATABASE
SQL Server (in my case express 2008 R2) is not a Database. In the management studio, when you log into the management studio, you can see that .\SQLEXPRESS (the root node) is called a server. It is important to read this article carefully when I talk about servers vs. databases, as it makes a difference.
LOGIN vs. USER
This is a little more blurry, but a login is not much more than a name, password, and a set of permissions to access the server. A user exists in databases, and has specific roles and permissions in an individual database.
Getting Started
In the Mode
First, make sure your server is in the mode (mood?) to use both kinds of authentication.
Open SQL Server Management Studio and right-click the SERVER name. Pick properties.
Then on the Security tab, make sure SQL Server and Windows Authentication mode is selected.
If it wasn't, then you'll need to save the change and restart SQL Server. If it was already selected you can skip this section.
Restarting SQL Server
Return to the SQL Server Management Studio and right click the Server Name.
Select restart.
Create a Server Login
When we create logins, in general we want to create one login per user. First, log into management studio using windows authentication (or however you normally gain admin access). Under the server tree (not a database tree) select Security- Logins and pick New Login.
Add your login...
Make sure to add a password and select the default database.
On the User Mapping tab...
Select the checkbox by your database.
Enter dbo as the default schema
Check every permission that doesn't contain the word deny.
Note that there are some additional roles in my database that I had added previously.
On the Status tab, make sure grant and enabled are selected.
Click OK.
Using witch-hazel and fairy dust, Management studio will now create your LOGIN to the SERVER, and your USER in the DATABASE.
Look in the Databases tree and find the user created by the wizard.
Open his properties.
The General tab should look much like this.
Testing
To test your new user/login, open a second copy of SQL Server Management Studio.
Change to SQL Server Authentication and enter your user login info.
If you forgot the password (as I did about 6 times while writing this article) you can go back to the login tree in your first SQL Server Management Studio window and change it there, then try again.
Now it's easy to use this login in your programs to access this database. It's also easy to set database level permissions, roles etc.
in C# to create a connection string to access the database do this:
Bryan Valencia is a contributing editor and founder of Visual Studio Journey. He owns and operates Software Services, a web design and hosting company in Manteca, California.
Tuesday, March 29, 2011
Thursday, March 3, 2011
SQL Server 2008 R2 Express
Three Hours later...
What a bunch of USELESS CRAP!
For those who lack a life, the text in the box below is...
Bryan Valencia is a contributing editor and founder of Visual Studio Journey. He owns and operates Software Services, a web design and hosting company in Manteca, California.
What a bunch of USELESS CRAP!
For those who lack a life, the text in the box below is...
The following notes apply to this release of SQL Server only.And the log file it left says
Microsoft Update
For information about how to use Microsoft Update to identify updates for SQL Server 2008 R2, see the Microsoft Update Web site at http://go.microsoft.com/fwlink/?LinkId=108409.
Samples
By default, sample databases and sample code are not installed as part of SQL Server Setup. To install sample databases and sample code for non-Express editions of SQL Server 2008 R2, see the CodePlex Web site at http://go.microsoft.com/fwlink/?LinkId=87843. To read about support for SQL Server sample databases and sample code for SQL Server Express, see Databases and Samples Overview on the CodePlex Web site at http://go.microsoft.com/fwlink/?LinkId=110391.
Release Notes
For more information about late-breaking changes in this release of SQL Server, see the latest readme file at http://go.microsoft.com/fwlink/?LinkId=141691.
Documentation and Links
To install the .NET Framework SDK, see “Installing the .NET Framework SDK” in SQL Server 2008 R2 Books Online at http://go.microsoft.com/fwlink/?LinkId=141693.
For information about SQL Server 2008 R2 Surface Area Configuration, see the following SQL Server 2008 R2 documentation topics:
In SQL Server 2008 R2 Books Online: “Understanding Surface Area Configuration.”
In SQL Server 2008 R2 Setup Help: “Minimize SQL Server 2008 R2 Surface Area.”
In SQL Server 2008 R2 Books Online on MSDN: Understanding Surface Area Configuration at http://go.microsoft.com/fwlink/?LinkId=141692.
Overall summary:
Final result: Failed: see details below
Exit code (Decimal): -2068052398
Exit facility code: 1212
Exit error code: 1618
Exit message: Failed: see details below
Start time: 2011-03-03 15:55:52
End time: 2011-03-03 16:52:14
Requested action: Upgrade
Log with failure: C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20110303_155335\sql_engine_core_inst_ctp6_Cpu32_1.log
Exception help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=10.50.1600.1
Machine Properties:
Machine name: WEB1
Machine processor count: 2
OS version: Windows Server 2003
OS service pack: Service Pack 2
OS region: United States
OS language: English (United States)
OS architecture: x86
Process architecture: 32 Bit
OS clustered: No
Product features discovered:
Product Instance Instance ID Feature Language Edition Version Clustered
Sql Server 2008 SQLEXPRESS MSSQL10.SQLEXPRESS Database Engine Services 1033 Express Edition 10.1.2531.0 No
Sql Server 2008 SQLEXPRESS MSSQL10.SQLEXPRESS SQL Server Replication 1033 Express Edition 10.1.2531.0 No
Sql Server 2008 Management Tools - Basic 1033 Express Edition 10.0.1600.22 No
Package properties:
Description: SQL Server Database Services 2008 R2
ProductName: SQL Server 2008 R2
Type: RTM
Version: 10
SPLevel: 0
Installation location: d:\bf7ec28684b1818f6c3151c67288a7c8\x86\setup\
Installation edition: EXPRESS_ADVANCED
User Input Settings:
ACTION: Upgrade
AGTDOMAINGROUP: <empty>
BROWSERSVCSTARTUPTYPE: Automatic
CONFIGURATIONFILE:
CUSOURCE:
ENU: True
ERRORREPORTING: False
FAILOVERCLUSTERROLLOWNERSHIP: 2
FARMACCOUNT: <empty>
FARMADMINPORT: 0
FARMPASSWORD: *****
FTSVCACCOUNT: <empty>
FTSVCPASSWORD: *****
FTUPGRADEOPTION: Import
HELP: False
IACCEPTSQLSERVERLICENSETERMS: False
INDICATEPROGRESS: False
INSTANCEID: SQLEXPRESS
INSTANCENAME: SQLEXPRESS
ISSVCACCOUNT: NT AUTHORITY\NetworkService
ISSVCPASSWORD: *****
ISSVCSTARTUPTYPE: Automatic
PASSPHRASE: *****
PCUSOURCE:
PID: *****
QUIET: False
QUIETSIMPLE: False
RSCATALOGSERVERINSTANCENAME: Unknown
RSUPGRADEDATABASEACCOUNT:
RSUPGRADEPASSWORD: *****
SQLDOMAINGROUP: <empty>
SQMREPORTING: True
UIMODE: AutoAdvance
X86: False
Configuration file: C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20110303_155335\ConfigurationFile.ini
Detailed results:
Feature: Database Engine Services
Status: Passed
MSI status: Passed
Configuration status: Passed
Feature: SQL Client Connectivity
Status: Passed
MSI status: Passed
Configuration status: Passed
Feature: SQL Client Connectivity SDK
Status: Passed
MSI status: Passed
Configuration status: Passed
Feature: SQL Writer
Status: Passed
MSI status: Passed
Configuration status: Passed
Feature: SQL Browser
Status: Passed
MSI status: Passed
Configuration status: Passed
Feature: SQL Server Replication
Status: Passed
MSI status: Passed
Configuration status: Passed
Feature: SQL Compact Edition Runtime
Status: Passed
MSI status: Passed
Configuration status: Passed
Feature: Management Tools - Basic
Status: Passed
MSI status: Passed
Configuration status: Passed
Rules with failures:
Global rules:
Scenario specific rules:
Rules report file: C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20110303_155335\SystemConfigurationCheck_Report.htm
Bryan Valencia is a contributing editor and founder of Visual Studio Journey. He owns and operates Software Services, a web design and hosting company in Manteca, California.
Subscribe to:
Posts (Atom)
How to Auto-generate Order Line Item numbers for bulk uploads
I had a problem where I had 17000 line items to insert into 9000 orders. The system required line item numbers, preferably numbered 1throug...
-
Microsoft did a brilliant thing in SQL Server. I applaud them for this. You can actually pack more than one SQL Query into a stored proced...
-
I got a job from a client and it was a fixed bid. We pay you x dollars and you finish the work. BUT... The scope was ill-defined the "...
-
Ok, let's say you have a stored procedure that returns a value. Now lets say you want to test it in SQL Server Management Studio... This...