Wednesday, October 15, 2014

Database in Recovery Pending State



Database 'db_name' cannot be opened due to inaccessible files or insufficient memory or disk space.  See the SQL Server errorlog for details.
Looks like Log file got corrupted and not allowing the database to come online. 


First thing make sure you have .mdf and .ldf files in your drives. 
next verify 

select * from sys.sysdatabases where name ='db_name'

Verify the filename column sees the database .mdf file with full path. 

Next 

Execute the following commands to bring your database to online. 

alter database [db_databasename] set offline with rollback immediate
alter database [db_databasename] set online with rollback immediate
with this your database is online and accessible. 

I would also recommend to run the following command to make sure no corruption. 

DBCC CHECKDB ('db_databasename')

Friday, September 5, 2014

High PLE high Performance.

Page Life Expectancy commonly called as PLE,  is number of seconds a page will stay in the buffer pool. 
The longer the pages stays in memory cache, the higher the PLE is, the high PLE gives high performance. Each time request comes, first SQL Server will check in the memory cache if it exists or not. If the results or data is found in memory cache (which is also called as buffer pool) decreasing the search time, then it will display the results that is read from cache. If sql server could not find the information in cache then it will look for the data in pages (that is stored in hard disk) now we are increasing the search time. So the high PLE leads to high performance. Below is the query to check the PLE value. 

select 
[object_name],
[counter_name],
[cntr_value] as Current_value
from
sys.dm_os_performance_counters
where
[object_name] LIKE '%Manager%'
and
[counter_name] = 'Page life expectancy'

Also always Buffer cache hit Ratio should be 100 or close to 100.
Below is the query to check the Buffer cache hit Ratio.

Both values can be obtained from Perfmon tool by adding respective counters.

select 
[object_name], 
counter_name, 
cntr_value as current_Value
from 
sys.dm_os_performance_counters
where 
[object_name] LIKE '%Buffer Manager%'
and
[counter_name] = 'Buffer cache hit ratio'

Thursday, September 4, 2014

SQL Server Error Log Recycle (ERRORLOG file growing large)


SQL Server Error log is too large and has grown upto 24GB, it takes a lot of time to open and sometimes hangs and SSMS gets into not-responding state.

Go to the location of the error log and see what's the size as shown in the pics below.
If you don't know the location of file, open management studio new query and execute the below query

use master
go
xp_readerrorlog 0, 1, N'Logging SQL Server messages in file', null, null, N'asc' 
go

From the results set in the text column you can find the location of your error log file.

Recycle log means creating the new error log file to start recording events in the new file so that its easy to search something in a new file rather that has fewer events rather than searching large file takes time.

Open management studio connect to the Instance, open new query.
and run the following statement.

use master
go
exec sp_cycle_errorlog
go


New ERROLOG file will be created by renaming the older file (24Gb) to ERRORLOG.1. You can comfortably delete the file to save space if you don't need it.
and expand the management studio you will see two files.

1) Current being the new file and starts to record new events.

2 Archive being the old recorded events, if you don't need it you can delete the physical file from the location.







Monday, July 21, 2014

Where does SQL Server 2012 License Key gets stored?

Many of my folks had a question about MicroSoft SQL Server License Key.

SQL Server license key can be found at the below location the registries. 

launch REGEDIT(Registry Editor) from the command prompt type: regedit

Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\110\Tools\Setup DIGITALPRODUCT ID

Connecting to the Integration Services service on the computer "SERVER_NAME" failed with the following error: "Access is denied."

TITLE: Connect to Server
------------------------------
Connecting to the Integration Services service on the computer "SERVER_NAME" failed with the following error: "Access is denied."
By default, only administrators have access to the Integration Services service. On Windows Vista and later, the process must be running with administrative privileges in order to connect to the Integration Services service. See the help topic for information on how to configure access to the service.
------------------------------
Connecting to the Integration Services service on the computer "SERVER_NAME" failed with the following error: "Access is denied."
By default, only administrators have access to the Integration Services service. On Windows Vista and later, the process must be running with administrative privileges in order to connect to the Integration Services service. See the help topic for information on how to configure access to the service.


This error occurred when I upgraded SQL Server 2008R2 to SQL Server 2012.
Everything was working until then, then I realized going back to old school its permission error, after integration services installed as an administrator needs to grant access to the users and groups who were in earlier version of SQL Server 2008R2, 2005 including me who actually installed\upgraded to sql 2012.

Here is the fix that I used it works after I granted access to the users or groups as below to DCOM.
First launch Component services.
from Search type component or from command prompt  type Dcomcnfg.exe and hit enter.
And from the below figure expand DCOM Config, to the
MicroSoft SQL Server Integration Services 11.0
1) Right click and select Properties.
2) Select Security Tab
3) On Launch and Activation Permissions select Edit.
4) now Add the member or groups that needs access to Integration Services.
and Finally Restart your Integration Services and Restart SSMS.


.

Friday, June 27, 2014

Cannot see ODBC Driver after installation of Oracle 11g client.


I installed the ORACLE client tool full Administrator option
Still not able to see the ODBC drivers for Oracle?



I know I have installed full administrator. Now next thing what I did was I went back and verified what version of Oracle Client I installed, I found it was 32 bit and My server is windows server 2008 r2 is 64 Bit.
So that explains we have a compatibility issues.

Without again re-installing 64 bit Oracle 11g client.
I went into
C:\Windows\SysWOW64\odbcad32.exe and launched the ODBC data source Administrator.
Now I see all the driver of 32 bit that I installed.



In my case I need 32 bit drivers, so If you still need 64 bit drivers Please install 64 bit client Oracle 11G drivers only. 



Tuesday, February 4, 2014

Error: 9003, Severity: 20, State: 9 SQL Server 2012

I have got this error message earlier this morning and all my user database backups failed due to this.

The log scan number (87817:27:0) passed to log scan in database 'AdventureWorks2012' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during Startup.

These are the steps that I took to resolve the issue.

I ran DBCC CHECKDB 
and there are lot of allocations errors and database has been corrupted. 

Fix1: Restore the Previous nights good backup can fix this. 

Before you restore make sure you have good backup it can be verified by running the below.

RESTORE VERIFYONLY FROM DISK = H:\Backups\AdventureWorks2012.BAK
GO
and then restore to the earlier nights good backup.

================================================================

Fix2: 
Rename your log file or move your log file to different location. 
You can you do this by detaching the database first and then move the files or rename the files. 

USE master;
GO
EXEC sp_detach_db @dbname = 'AdventureWorks2012';
Now rename the .ldf  file or move to a different location.
CREATE DATABASE AdventureWorks2012 
    ON (FILENAME = 'D:\MSSQL\DATA\AdventureWorks2012_DATA01.mdf')
   --(FILENAME = 'E:\MSSQL\LOGS\AdventureWorks2012_LOG01.ldf') 
    FOR ATTACH;

OR


EXEC sp_attach_single_file_db @dbname = 'AdventureWorks2012', 
    @physname = 
N'MSSQL\DATA\AdventureWorks2012_DATA01.mdf';

Note: I commented .LDF file attachment, without it a NEW log file will be created in the default location.
and run the DBCC CHECKDB (Databasename)