Friday, February 11, 2011

Planning trip to Florida

When we went we took SFO-Orlando-SFO flight. Stayed in Orlando for 2 days then drove from Orlando to Key west. On way went to Miami south beach and everglades national park. Then spend 2 days in Key west. Orlando to Miami is approx 3-4 hours drive and Miami to Key west is another 3-4 hours.

Orlando -
First day we went to Epcot (http://disneyworld.disney.go.com/parks/epcot/) which is worth going to. It has small sets from different countries around the world. You can try world food and drinks.
Second day we went to Cape Canaveral - JFK Space Center which is space museum (http://www.kennedyspacecenter.com/). Cape Canaveral is about 1 hour drive from Orlando. And in end of Feb they have LAST shuttle launch scheduled which draws huge crowds so check that schedule.
Disney world is also there but mostly for kids and we have been to one in San Diego. :)
Look for park tickets online since there are good deals available. Also check in Costco they also have package deals. (I booked via AAA). Orlando we stayed at a friends place but there are many hotel options. Try to stay close to Disney downtown (all parks are around it)
Miami - South beach is THE place in miami. Good beaches so u can spend some time on way to key west. have food etc. we spent couple of hours there
Everglades national park - it is on way from Miami to Key west (http://www.nps.gov/ever/index.htm). They have small zoo and air boat rides (which is awesome). Spent about 3-4 hours here

Key west - in key west hotels r expensive so we stayed in banana bay resort Marathon, FL (http://www.bananabay.com/activities.php). Hotel is old but ok. Booked room for $67/day. They have pool side tiki bar and live music in eve . Key west is about 50 mins drive from here. In key west we did para sailing, glass boat ride, scuba diving with Fury adventures. (check their website they have a package for everything www.furycat.com). They have AAA discount.

This schedule was little hectic specially since we drove from Orlando to Key west and went to other places on the way. But the trip was totally worth money and time spent.

NetFlix Error N8156-6022: Problem with Internet connection

NetFlix Error N8156-6022: Problem with Internet connection

I got this error several times and found out that this is related to Microsoft silverlight

You will see this error when you plan some movie online (on computer) and get an error saying there is “some problem with your internet connection”

Basically this is problem with Silverlight

To fix go to
1. Close all open Internet Explorer browsers
2. Start --> Run
3. Type %allusersprofile%
4. It will take you to C:\Documents and Settings\All Users.WINDOWS
5. Make sure Show hidden files is ON in Tools --> folder options menu on windows explorer
6. Then browse to following directory
C:\Documents and Settings\All Users.WINDOWS\Application Data\Microsoft\PlayReady
7. Delete the file MSPR.HDS
8. Start IE and play the movie.

Wednesday, December 22, 2010

How to setup database mail in SQL Server 2005?

How to setup database mail in SQL Server 2005?

Here is a small code snippet for setting up database mail.

Please make sure to do following before setting up database mail

  1. Enable database mail in SQL Server Surface Area configuration by clicking on “Surface area configuration for features”


  1. Select server instance

  1. Click on database and enable database mail SPs



  1. Click on SQL mail and enable SQL Mail SPs



  1. Now you are all set for creating and managing database mail profiles

Here is a script to do it

-------------------------------------------------------------
--  Create a Database Mail profile, an SMTP account and
--  associates the account to the profile.
-- 
-------------------------------------------------------------
DECLARE @profile_name sysname,
        @account_name sysname,
            @description nvarchar(256),
        @SMTP_servername sysname,
        @email_address NVARCHAR(128),
          @display_name NVARCHAR(128);
-- Profile name. Replace with the name for your profile
        SET @profile_name = 'SQLMAIL';
-- Account information. Replace with the information for your account.
            SET @account_name = 'SQLMAIL';
            SET @SMTP_servername = 'smtp.MyCompany.com';
            SET @email_address = 'sqlsa@MyCompany.com';
        SET @display_name = 'SQLMAIL';
            SET @description  = 'Mail account for Production Maintenance.'

-- Verify the specified account and profile do not already exist.
IF EXISTS (SELECT * FROM msdb.dbo.sysmail_profile WHERE name = @profile_name)
BEGIN
  RAISERROR('The specified Database Mail profile SQLSA already exists.', 16, 1);
  GOTO done;
END;

IF EXISTS (SELECT * FROM msdb.dbo.sysmail_account WHERE name = @account_name )
BEGIN
 RAISERROR('The specified Database Mail account SQLSA already exists.', 16, 1) ;
 GOTO done;
END;

-- Start a transaction before adding the account and the profile
BEGIN TRANSACTION ;

DECLARE @rv INT;

-- Add the account
EXECUTE @rv=msdb.dbo.sysmail_add_account_sp
    @account_name = @account_name,
      @description = @description,
    @email_address = @email_address,
    @display_name = @display_name,
    @mailserver_name = @SMTP_servername;

IF @rv<>0
BEGIN
    RAISERROR('Failed to create the specified Database Mail account SQLSA.', 16, 1) ;
    GOTO done;
END

-- Add the profile
EXECUTE @rv=msdb.dbo.sysmail_add_profile_sp
    @profile_name = @profile_name,
      @description = @description;

IF @rv<>0
BEGIN
    RAISERROR('Failed to create the specified Database Mail profile SQLSA.', 16, 1);
      ROLLBACK TRANSACTION;
    GOTO done;
END;

-- Associate the account with the profile.
EXECUTE @rv=msdb.dbo.sysmail_add_profileaccount_sp
    @profile_name = @profile_name,
    @account_name = @account_name,
    @sequence_number = 1 ;

IF @rv<>0
BEGIN
    RAISERROR('Failed to associate the speficied profile with the specified account SQLSA.', 16, 1) ;
      ROLLBACK TRANSACTION;
    GOTO done;
END;

COMMIT TRANSACTION;

done:

GO

Where is my table?

Where is my table?

I find it really annoying that users create tables with same name in multiple databases in development and sometimes production environment. They one fine day they compare the tables in and find the data different. This creates a big problem for DBAs figuring out what all places table exists. So here is a small script to do just that

exec master.dbo.sp_msforeachdb
"USE [?]
select      db_name()
from  sysobjects
where name = 'mytable'
"

Tuesday, December 21, 2010

Find Deprecated Features in SQL Server


Few days back I was working on project which involved server migration from SQL 2005 to SQL 2008. I wanted to find out what code that I use will not be available in the next version of SQL. These features are called as “deprecated features”. Now MS provides all kind of documents and links to read about it. But being a DBA I want to run a query and see the results J

Following will help you do it when it comes to deprecated features

SELECT * FROM sys.dm_os_performance_counters WHERE object_name LIKE ('%deprecated%')

object_name
counter_name
instance_name
cntr_value
cntr_type
SQLServer:Deprecated Features 
Usage
ALTER LOGIN WITH SET CREDENTIAL
0
65792
SQLServer:Deprecated Features
Usage
SQL_AltDiction_CP1253_CS_AS
0
65792
SQLServer:Deprecated Features
Usage
Macedonian
2
65792
SQLServer:Deprecated Features
Usage
Lithuanian_Classic
2
65792


How to read the results

object_name
Category to which this counter belongs
counter_name
Name of counter
instance_name
Name of the specific instance of the counter. Often contains the database name.
cntr_value
Current value of the counter.
cntr_type
Type of counter as defined by the Windows performance architecture.


How to send a CSV or XLS file as attachment using SQL Database mail with proper formatting


Today I encountered a weird (may be not) problem…. One of my colleagues was asked to generate a CSV file and email it to someone. He was getting ready to create a SSIS package with data flow task and everything. I thought why to waste time doing this when there is functionality available in SQL Server. Here you go…

Now please remember that the parameter @query_result_separator = ' ' needs to be re-typed to TAB if you are copy pasting the code. When you copy and paste the formatting in SSMS resets it to something else and the formatting in CSV file is all messed up

DECLARE @sub VARCHAR(100)
DECLARE @qry VARCHAR(1000)
DECLARE @msg VARCHAR(250)
DECLARE @query NVARCHAR(1000)
DECLARE @query_attachment_filename NVARCHAR(520)

SELECT @sub = 'TEST XML ATTACHMENT'
SELECT @msg = 'Please refer to the attached spread sheet for the report.'
SELECT @query = ' SET NOCOUNT ON;
            Select top 10 * from master..sysobjects WITH(NOLOCK)  '

SELECT @query_attachment_filename = 'test.csv'

EXEC msdb.dbo.sp_send_dbmail
            @profile_name = 'SQLMAIL',
            @recipients = 'sqldba@sqldba.com',
            @copy_recipients = 'sqldba@sqldba.com',
            @body = @msg,
            @subject = @sub,
            @query = @query,
            @query_attachment_filename = @query_attachment_filename,
            @attach_query_result_as_file = 1,
            @query_result_header = 1,
            @query_result_width = 256 ,
            @query_result_separator = '   ' ,
            @query_result_no_padding =1;