Friday, June 29, 2012

Lost Sa Password for SQL Server 2008, 2008 R2, 2005

Below steps helps to reset the "sa" password if you forgot or lost without install SQL Server



1. Login into server using Administrator login
2. Open SQL Server Configuration Manager
3. Select SQL Service - Properties - Advanced -- Need to add (-m;) parameter to startup parameter of the
SQL Service, to start SQL Server in single user mode to reset the "sa" password
Note - Dont give any space after semicolon. Add -m; parameter starting itself it looks like below
-m;-dc:\program..........
4 Restart the SQL Service
5. Open Command Prompt
6. Run SQLCMD
If you have two instances running on server say SQL 2008 R2, SQL 2012, then issue command as below
7. SQLCMD  -SKALYAN\SQL2008
1>
After invoking the SQLCMD it should display 1> prompt indicates login into server with admin login


Possible Errors

You may receive the below error when you run SQLCMD from command prompt
Login failed for domain\user or user doesnot have sysadmin permissions

If you got the above error please stop the SQL Service and change the built-in account to Local System and start the service in single user mode and run the below steps

1> select @@servername
2>go

1> create login [domain\kalyan] for windows;
2> go

1> sp_addsrvrolemember 'domain\kalyan','sysadmin';
2> go


If NP (named pipes) is not enabled in your system you may encounter the below error
C:\Users\kalyan>sqlcmd
HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired.
Then Enable the Named Pipes protocol from SQL Server configuration manager then again invoke 7th step
Issue the below commands to enable / reset sa password

1> select @@servername --> Make Sure Instance name is correct
2> go
1> alter login sa with password='kalyan@'
2> go
1> exit
1> alter login sa enable
2> go

Remove the (-m;) parameter from the SQL Server startup parameters, Restart the SQL Service and then Open SSMS with SQL Authentication. Then change the sa password as you like.





Thursday, June 28, 2012

Cant Uninstall SQLServer 2008 Express Tools


I recently encountered the below error while uninstallting SQL Server 2008 Express tools, because the insallation got failed and not moving forward.

SQL Server Setup has encountered the following error:
No feature were uninstalled during the setup execution. The requested features may not be installed. Please review the summary.txt logs for further details.
Error code 0x84B30002.
Follow the below steps it may help to uninstall, Before follow this procedure please make sure you have some idea about registry

1. Open Registry Editor
2. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
3. Browse Ids one by one and identify the GUIDs for SQL Server 2008
4. Run the below command for all SQL Server 2008 Guids one by one
From command prompt

msiexec /x "Guid"

Remove all Guids which are releated to SQL Server 2008 R2 / Express
Restart the system and verify in the control panel - program and features

Then you can proceed with a fresh copy of installation.

Sunday, June 24, 2012

'syspolicy_purge_history' cannot be run because the powershell subsystem failed to load

We may face the below error while running few jobs which has powershell script associated to any of the job steps.

Error Message
'syspolicy_purge_history' cannot be run because the powershell subsystem failed to load

We can fix the issue by updating the value in one of the system table in MSDB database.
syssubsystems - It contains information about all available SQL Server agent proxy subsystems. It is stored under MSDB database.

1) Use msdb
select * from syssubsystems
2) Verify the record of powershell subsystem, need to verify two things
  a) subsystem_dll  b) agent_exe
If there is any mismatch in the dll path or exe paths, then we need to update the entries with accurate paths.
3) This is a system table, so we need to run the below command to allow updates into system tables.
EXEC sp_configure 'allow updates', 1;
reconfigure with override;
Prepare the update command / delete complete information the table.
4) To Re-Populate
exec msdb.dbo.sp_verify_subsystems 1 / Restart the SQL Server Agent Service
5) Disallow updates
EXEC sp_configure 'allow updates', 0;
reconfigure with override;