Help: SQL Server

Sharing my knowlege about SQL Server Troubleshooting Skills

  • Blog Stats

    • 1,983,243 hits
  • Select GETDATE()

    May 2022
    M T W T F S S

Archive for the ‘Step by Step’ Category

Step by Step – Configuring SQL Server 2012 AlwaysOn in Windows 7 Virtual Environment (Part 1)

Posted by blakhani on May 3, 2012

I have been demonstrating AlwaysOn feature to various audiences on various forums (TechEd, SQL Saturday, Virtual TechDays etc.). I have been using Windows Server 2008 R2 with Hyper-V to create multiple machine and demonstrate the feature. Someone asked me if he can do the same thing using his Windows 7 laptop? I tried looking at virtualization techniques available on Windows 7 and I found that it should be possible. I have tried to make it as descriptive as possible with step by step screenshots to configure whole setup.This topic would be a multipart series.

  1. Configure Windows 7 to use Virtualization and Configure three machines (One domain controller, two member servers). Also configure networking between them.
  2. Create Domain and configure the machines to make sure they are able to talk to each other.
  3. Install SQL Server 2012 on the servers.
  4. Configure AlwaysOn.

First download Windows Virtual PC on Windows 7 machine. Go to and choose below option. I am not going to Install Windows XP mode.


One clicked, choose your platform and language and click on download button.


This would install Windows Update to enable Virtual PC

03_Windows Installer


Restart the machine and you should be able to see below under "Start” > “Programs” > “Windows Virtual PC”

04_Windows Virual PC Shortcut

Next step would be to download the Virtual Hard Disk (a.k.a. VHD) file which I can use to configure my machine. Note that You need to use 32 bit images to make this work. Here is the link to download Windows Server 2008 images (Windows Server 2008 Enterprise Edition x86 (Full Install) VHD)

There are three parts which you need to download and then extract to user by Virtual PC. It would look like below.

05_Downloaded VHD

Double Click on the File and Extract the data into “C:\VHDs\DC” folder as shown below:


Once extraction is complete, make three copies of the vhd (Windows2008Fullx86Ent) file and keep them in separate folders as shown below. [I am showing only two, same exists for Srv2 also]


Lets add the machine to Virtual PC. Open the UI from "Start” > “Programs” > “Windows Virtual PC” > “Windows Virtual PC” and choose “Create virtual machine”

08_Create Machine 

Follow the wizard and create DC

09_Create Machine1 

10_Create Machine_Mem

11_Create Machine_Disk

One done, lets go to network setting and choose “Internal Network” This is because I don’t want to create domain controller in my office domain network.

Right Click on DC and choose “Settings”


Go to Networking option and choose “Internal Network”


Now start the first machine and make sure we are able to log in.


You need to follow few steps which are pretty self-explanatory. It would also as you to set machine name (I have given name as DC) new password for Administrator. Once you are done with that, this is what you should see 🙂


As homework, before moving to second part, you need to do the same thing with two more machines and here is what you should see in Windows Virtual PC.

16_Three Machines

See you at next part of Series!

Hope this would help someone in the world!

Balmukund Lakhani
Twitter @blakhani

Posted in AlwaysOn, Denali, Images, Installation, Installation Guide, Introduction, screen shot, Screenshot, SQL Server 2012, Step by Step | 4 Comments »

Help : I purchased proper media to upgrade SQL version, still setup thinks that its Evaluation. What’s wrong?

Posted by blakhani on February 12, 2012

Have you came across the scenario where you are performing a version upgrade of SQL Server as per supported path described here but still you are facing below error message during rules check?

Rule "SQL Server 2008 R2 Feature" failed.

The specified edition upgrade is not supported. For information about  supported upgrade paths, see the SQL Server 2008 R2 version  and edition upgrade matrix in books online.

If you look at Detail.txt file created by setup, search for “FeatureUpgradeMatrixCheck” and have a closer look at the log. From the highlighted you can easily understand the source and destination version+edition. So as per below log, setup is trying to upgrade from SQL 2000 Standard to Evaluation Edition (which is not in the link I provided earlier)

2011-01-27 22:53:34 Slp: Init rule target object: Microsoft.SqlServer.Configuration.SetupExtension.SkuUpgradeRule
2011-01-27 22:53:34 Slp: — SkuUpgradeRule : Rule ‘FeatureUpgradeMatrixCheck’ looking for previous version upgrade data for feature package ‘sql_as_Cpu32’.
2011-01-27 22:53:34 Slp: — SkuUpgradeRule : Rule ‘FeatureUpgradeMatrixCheck’ feature package ‘sql_as_Cpu32’ found no upgrade features.
2011-01-27 22:53:34 Slp: — SkuUpgradeRule : Rule ‘FeatureUpgradeMatrixCheck’ looking for previous version upgrade data for feature package ‘sql_engine_core_inst_Cpu32’.
2011-01-27 22:53:34 Slp: — SkuUpgradeRule : Found feature package  ‘Sql2000Ent_Cpu32’ with SkuValue=STANDARD ProductVersion=8.00.2039
2011-01-27 22:53:34 Slp: — SkuUpgradeRule : Rule ‘FeatureUpgradeMatrixCheck’ found sourceVersion 8.0 and edition STANDARD for feature package ‘sql_engine_core_inst_Cpu32’.
2011-01-27 22:53:34 Slp: — SkuPublicConfigObject : ValidateSkuMatrix checking sku matrix for sourceVersion=8.0 sourceEdition=STANDARD sourceArchitecture=X86 targetEdition=EVAL targetArchitecture=X86
2011-01-27 22:53:34 Slp: — SkuPublicConfigObject : ValidateSkuMatrix source and target architecture match.
2011-01-27 22:53:34 Slp: — SkuPublicConfigObject : ValidateSkuMatrix did not find a match in sku matrix .
2011-01-27 22:53:34 Slp: — SkuUpgradeRule : Rule ‘FeatureUpgradeMatrixCheck’ feature package ‘sql_engine_core_inst_Cpu32’ is blocking upgrade.
2011-01-27 22:53:34 Slp: — SkuUpgradeRule : Rule ‘FeatureUpgradeMatrixCheck’ detection result: IsValidFeatureUpgrade=False
2011-01-27 22:53:34 Slp: Evaluating rule        : FeatureUpgradeMatrixCheck
2011-01-27 22:53:34 Slp: Rule running on machine: SQLSERVER
2011-01-27 22:53:34 Slp: Rule evaluation done   : Failed
2011-01-27 22:53:34 Slp: Rule evaluation message: The specified edition upgrade is not supported. For information about supported upgrade paths, see the SQL Server 2008 R2 version and edition upgrade matrix in Books Online.
2011-01-27 22:53:34 Slp: Send result to channel : RulesEngineNotificationChannel
2011-01-27 22:53:34 Slp: Initializing rule      : Incomplete upgrade
2011-01-27 22:53:34 Slp: Rule applied features  : SQL;SQLEng

On a side note, Do you know the media difference for Standard and Evaluation edition? Well, there is no difference! Its the PID (Product ID) in below screen which decides the edition to be installed. The value of PID is picked from DefaultSetup.Ini file located on media. If there is no such file on Media then it would be enterprise evaluation edition of SQL Server.

Here is the little test which would prove the theory. I swear to god that I have not hit cancel while doing the test. Its the same media used for all the screen (Evaluation Media) All I did was change value in Enter the Product Key and hit next> or previous<.





Since I had media for various editions (How? Did I tell you that I work with Microsoft SQL Support team.. lol!), I copied/pasted the PID from DefaultSetup.ini file and rest can be seen above.

You might say, Nice to know what’s happening behind the scene but what you need to do if you run into such situation. In my scenario customer informed that they purchased Standard edition of SQL Server 2008 R2 still its taking EVAL in targetEdition and there has to be flaw somewhere. Later we found that screen was selecting Enterprise Evaluation by default (not sure why) So once he entered the Product Key, it worked like a charm!

Now, go ahead with the setup and post a comment here if this helped.

Balmukund Lakhani
Twitter @blakhani

Posted in Edition Upgrade, Error, Evaluation, Images, PID, Product Key, Screenshot, SQL Server, Step by Step, Version Upgrade | Tagged: , , | 2 Comments »

Help : I lost sa password and no one has System Administrator (SysAdmin) permission. What should I do?

Posted by blakhani on February 8, 2012

If you are thinking that I am going to show you black magic to recover sa password or other login’s password then you have hit the wrong blog post. go back to search engine and search for better tool/utility. Smile

After spending many years with SQL Server product, I have seen situations where someone wants to get in to SQL Server as system administrator as someone recently left company who had System Administrator permission (or hundred other reasons). Till SQL 2000 days, it was impossible to solve such problem other than reinstalling SQL Server. Here are the typical questions I saw in forum:

  • Only sysadmin user is SA and I Lost SA password.
  • I am locked out of SQL server i.e. that no windows users are added (or removed them) as sysadmin and I forgot the password for sa
  • I am windows admin. How can I get sys admin privileges on SQL server express as I removed all sysadmin accounts from SQL.

Here are the various error you might see

  • Unable to create new database. This is generic error which means that you are not having permission.


TITLE: Microsoft SQL Server Management Studio
Create failed for Database ‘SQLServer-Help’.  (Microsoft.SqlServer.Smo)

For help, click:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
CREATE DATABASE permission denied in database ‘master’. (Microsoft SQL Server, Error: 262)
For help, click:

  • When you login to Management Studio, you would see only your own account and ‘sa’ as shown below


  • When you attempt to change password of ‘sa’ you might see below error.


TITLE: Microsoft SQL Server Management Studio
Change password failed for Login ‘sa’.  (Microsoft.SqlServer.Smo)
For help, click:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Cannot alter the login ‘sa’, because it does not exist or you do not have permission. (Microsoft SQL Server, Error: 15151)
For help, click:


All error messages appear because your account is not a System Administrator of SQL Server Instance.

So, what should you do now? Answer is simple, get yourself added as System Administrator. I know, you would say “don’t you think I have tried that as I got this error!”


TITLE: Microsoft SQL Server Management Studio
Add member failed for ServerRole ‘sysadmin’.  (Microsoft.SqlServer.Smo)
For help, click:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
User does not have permission to perform this action. (Microsoft SQL Server, Error: 15247)
For help, click:


Okay, here is the step by step guide to add any account as System Administrator of SQL Server. This is documented and completely supported way to gain back the rights.  To log into SQL Server as SysAdmin, you need to have Local Administrator permission on the windows which is hosting SQL Server. If you don’t have that also then you may want to check with your windows team to get access (I am not a windows guy)

Steps to login to SQL Server as System Administrator. [Provided you are having windows local administrator permissions]

  • Stop the SQL Server Service using ANY of below command.
    • Net Stop MSSQLServer (for default instance) / Net Step MSSQL$<InstanceName> If you want to know instance name, refer my earlier blog
    • Use SQL Server Configuration manager and stop the SQL service. [Start>Programs>Microsoft SQL Server 2005>Configuration Tools>SQL Server Configuration Manager]
    • Use Services console [ Start > Run > Services.msc] and locate the SQL instance you want to stop.
  • Start SQL Server in Single User mode. You need to use start-up parameter m to start SQL Service in single user mode. I prefer command line but its your choice.
    • Using command line
      • net start MSSQLServer /m SQLCMD        [For default instance]
      • net start MSSQL$<InstanceName> /m SQLCMD     [For named instance]
    • Using configuration Manager
      • Locate the service which you have stopped earlier. Go to its properties, “Advanced”, click on drop down at “Startup Parameters”  and add ;-mSQLCMD as shown below


You might notice that I have use SQLCMD after m. That’s not a typo. Many times, when you start SQL Server in single user mode, application grabs connection before you could. SQLCMD ensures that only SQLCMD program can connect to SQL Server when its running in single use mode. Here is the error you might see if above happens. SQLCMD should be in UPPERCASE. else that would also show same error. Please make sure there is no space between “;” and “-m”, the registry parameter parser is sensitive to such typos. You should see an entry in the SQL Server ERRORLOG file that says “SQL Server started in single-user mode.”

TITLE: Connect to Server
Cannot connect to (local)\SQL2k8R2.
Login failed for user ‘Contoso\demouser’. Reason: Server is in single user mode. Only one administrator can connect at this time. (Microsoft SQL Server, Error: 18461)
For help, click:

  • Connect to SQL Server and add desired account in SysAdmin role.
    I normally prefer to do it from SQLCMD (that’s why I added SQLCMD after m)
    • Open administrator command prompt. (i.e. right click on command prompt shortcut and choose “Run As Administrator”
    • Type sqlcmd –S <complete instance name> For example
      • sqlcmd –S. (for default instance)
      • sqlcmd –S.\MyInstance
        For getting exact name, your my earlier blog
    • You are connected as System Administrator, because you are part of local administrator group in windows.
    • At this point you can add any account to sysadmin because you are connect as sysadmin. Here is the script I normally use to add local administrator group as a part of SysAdmin group in SQL Server Instance. You may want to tweak this as per your needs because I am adding all local admin as sysadmin which is not a good practise.

USE [master]
EXEC master
..sp_addsrvrolemember @loginame = N’BUILTIN\Administrators’, @rolename = N’sysadmin’

  • Here is how it would look on sqlcmd command prompt


  • Stop SQL Server Service. You can use any method as described in first step
  • Start SQL Service normally. This means that you need to remove startup parameter

Here is the MSDN reference for above, just to show that its documented.

So, to conclude, I have not shown any trick to recover any password. Just showed you detailed steps to gain sysadmin access provided you have windows admin rights.

DISCLAIMER: Use the method that is described in this article only as a failure recovery mechanism

Posted in Configuration Manager, ERRORLOG, forgot sa password, Forgot the SA password in Sql Server 2005, sa password lost, screen shot, Screenshot, Security, SQL Server, Step by Step | 41 Comments »