OraOLEDB.Oracle Linked Server

Do you want to use Oracle’s driver to directly connect to an Oracle database instead of using ODBC (DSN)? Is it any faster? You be the judge!

Step 1

Make sure you have Oracle 12g drivers installed on the server. This could be any version of Oracle

Step 2

Make a note as to where your Oracle installation path is. You’ll need a few information from the TNSADMIN.ora file. For example, my path is C:\Oracle\Ora12\Network\Admin\tnsadmin.ora

Inside tnsadmin.ora, you’ll need the HOST, PORT, and SERVICE_NAME

Step 3

In SSMS, navigate to the OraOLEDB.Oracle providers and open up the properties

Enable Allow inprocess

Step 4

Create a Linked Server

  1. Linked Server: Call this Linked Server whatever you want
  2. Provider: Select Oracle Provider for OLEDB
  3. Product name: Call this whatever you want
  4. Data source: This information comes from Step 2 in this format HOST:PORT/SERVICE_NAME i.e.(My_Host.afterowl.com:1571/My_Service_Name.afterowl.com)
  5.  Click on the Security tab on the left and use Be made using the security context. Then click OK to create the Linked Server
Step 5

This is how you would use your new shiny Oracle Linked Server

SELECT * FROM OPENQUERY(“ORACLE”, ‘SELECT * FROM MyTable’) AS MyTable

Advertisements

In Recovery Status

Sometimes a very large database (VLF) stalls and or takes forever and a day to perform a 2 minutes task. In these fun times we restart the server. It gets funner when the server is back online and your database is IN RECOVERY.

This generally happens prior to the server restart, you still have large transactions running (i.e. millions/billions or records being DELETE/UPDATE/INSERT).

To check on the status of your database simply run

EXEC sys.sp_readerrorlog 0, 1, ‘Your_Database_MDF_Name’

At this point, you can’t use sp_helpfile because your database is inaccessible therefore navigate to where the mdf file is located. Most of the time, the mdf file is the same name as your database.

When you run the command above, in your message tab you’ll see the percentage of completion and how many seconds to go.

 

WAITFOR it …

There are times when you want to delay a script such as sending yourself a reminders or to run a job/stored procedure/etc.

Wait by Time

BEGIN
             WAITFOR TIME ’01:10′;
PRINT ‘This message will print at 1:10 am’;
END;

Wait by Delay

BEGIN
             WAITFOR DELAY ’01:00′;
PRINT ‘This message will print in one hour’;
END;

SQL Back Door – DAC (Dedicated Administrator Connection)

There will be a time or more in your life where SQL Server becomes unresponsive and stops working. You can try to remote desktop into the server with no luck– or take the Rambo route and hard restart the server or have IT do it. This is where DAC (Dedicated Administrator Connection) comes into play. DAC allows one back door SA connection into the SQL Server. To use DAC, you first have to turn it on and here’s how you do it.

GUI Method

First open up SQL Management Studio

Step 1. Right click on your server

Step 2. Click on Facets


Once the Facets windows show up do the following

Step 1. Under the Facet drop-down-list, pick Surface Area Configuration

Step 2. Select RemoteDacEnabled and from the drop-down-list pick True

Step 3. Click OK

That’s all to it

If you prefer the T-SQL method

USE master

GO

sp_configure ‘remote admin connections’, 1

GO

RECONFIGURE WITH OVERRIDE

GO

How to log onto the server using DAC

Step 1: Open up SQL Server Management Studio (SSMS)

Step 2: On the tool bar, click on Database Engine Query


Step 3: In the Server Name box, type in ADMIN: before your server name.

Step 4: Click Connect

Once connected, you can then troubleshoot your SQL Services. If you can’t log in, it means two thing.

  1. You don’t belong in the SysAdmin group
  2. A SysAdmin is already logged onto the server

As always, I hope this helps.

Fail-Safe

There are times when you’re on vacation, kids soccer games, family outing, church, etc where you’re inaccessible. Thanks to Murphy’s law something bad will happen to the database server and alerts will fire off and you won’t receive those notifications because you’re enjoying life for once. This is where you want to enable Fail-Safe– a.k.a. your backup buddy.

As TechNet puts it, “when things go wrong with SQL Server notifications, operators are not notified and problems might not be corrected in a timely manner. As a precaution, you might want to designate a fail-safe operator. A fail-safe operator is notified when a SQL Server Agent cannot access system tables in the msdb database (which is where operator definitions and notification lists are stored), when all pager notifications to designated operators have failed, or when the designated operators are off duty (as defined in the pager schedule). ”

The steps to enable this tucked away feature is as follows.

Open up Management Studio -> Right Click on SQL Server Agent -> Click on Properties

Click on “Alert System”

Tick the “Enable mail profile” as you’ll need this for the Fail-Safe to work.

I’m assuming you already have a Mail Profile setup so at this point, select your Mail System/Profile from the drop-down-list. Once this is done, the Fail-Safe operator will highlight.

Tick on “Enable fail-safe operator” and select your Operator from the drop-down-list. Then Tick on how you want that operator to receive the messages and then Click OK


As always, I hope this helps.

FREE SQL System Reports!

Are you a DBA that has no funding for fancy SQL System Health Reports like RedGate, SQLTools, Foglight, SentryOne, etc? Do you hate looking at dmv queries because there are so many of them to remember? Well did you know that SQL Management Studios comes with System Health Reports? Below are steps to get System Health Reports at no cost.

To view the System Reports

Right click on “your Server” -> Reports -> Standard Reports -> “select a report”

To view the Database Specific Reports

Right click on “your Database” -> Reports -> Standard Reports -> “select a report”

Each report can be expanded for detail information.

As always, hope this helps!