Saturday, June 09, 2012

Quarry Road Lookout – Beetaloo South Australia

If you are travelling in Beetaloo and also if you are enjoying the views of nature a good place to visit is Quarry road lookout. Quarry road it self is having some good views in your way. If you have sometime to spend there is a table and chair for you to sit down and have some food. Another good thing is you do not have to walk, you can park your car right in the lookout and enjoy.

Map


View Larger Map

Tuesday, June 05, 2012

Things to Remember when Travelling in Outback and Remote Places

I thought to share with you few things to remember while travelling in remote places. I know most of you are aware of these but thought to put a post since most of us forgets these even though we know these.

  • Always take sufficient amount of drinking water to survive for about 2 days.
  • Always take sufficient food supplies to survive for about 2 days.
  • Before starting your trip check your spare tyre.
  • Before leaving each town check your fuel level and calculate the fuel required to reach your next town.
  • Check for the fuel station opening and closing times of the town you are planning to visit.
  • Get a fly mask or at least carry some water in a bottle to use on face to escape the fly attack while in outback.
  • If you are not 100% familiarized with your vehicle do not speed too much.
  • Always watch for animals.
  • Take a blanket or two to keep you warm in case the unforeseen happen.
  • If you are taking any medication do not forget to take medicine.
  • It is always better to have a first aid kit while you are travelling.
  • If you have knowledge to repair then a tool kit will be handy.

I know there are many more things, so feel free to comment.

Hope these helps.

Saturday, May 05, 2012

Automatically Sizing Excel Columns

Today while trying to do some formatting on Excel using .Net I came up with an error.

One of the things I tried is to make Excel columns automatically size according to the content having on them. As all of you might know we can get this done in Excel by simply double clicking on the column’s right margin. While doing this in code I got the following exception.

ExcelSheet.get_Range("A1", "E10")' threw an exception of type 'System.Runtime.InteropServices.COMException'
base {System.Runtime.InteropServices.ExternalException}: {"Exception from HRESULT: 0x800401A8"}

The code involved in generating this error is as below.

  1. (ExcelSheet.get_Range("A1", "E10")).EntireColumn.AutoFit();

 

Later I found the reason for this error. Error will occur when we use AutoFit () on empty cells. Because initially I did not have anything in my excel sheet I kept on getting this. So to overcome this error use the same code to auto fit the cell contents simply after the cells are populated with values.

If you cannot get AutoFit () to work the reason might be the same thing. make sure the cells you apply auto fit have some values on them.

The best thing is to use AutoFit () after all data are entered into Excel sheet.

Monday, March 05, 2012

Dynamically Creating Computed Columns in SQL

If you are into programming you should have definitely worked with calculated fields in SQL. But for others I will briefly explain what they are.

Calculated columns are columns which depend on other columns. It gets its value by calculating which can involve values of other columns. The calculation formula is the only thing stored in the column.

So each time the column is referenced the calculation is done. But if you use the keyword “persisted” while creating the column then the values will be kept in the table. Whenever a referenced value is updated the computed column is also automatically updated to highlight the change. Also by using persisted you can index a computed column.

You can create a table with persisted computed column as follows.

  1. CREATE TABLE Customer
  2. (
  3. CustomerId INT IDENTITY(1, 1) NOT NULL,
  4. CustomerFirstName NVARCHAR(100) NOT NULL,
  5. CustomerLastName NVARCHAR(100) NOT NULL,
  6. CustomerFullName AS CustomerFirstName + ' ' + CustomerLastName PERSISTED
  7. )

One thing to remember is that you cannot directly insert values to a computed column.

I think you got a basic idea of computed columns. Now I would like to show how to create a computed column dynamically. For example think that you need to add a computed column to a table using a stored procedure. It is not a big deal.

I need to insert a TotalOrder column to the table named FoodOrder.

  1. CREATE TABLE FoodOrder
  2. (
  3. OrderId INT IDENTITY(1, 1) NOT NULL,
  4. OrderDate SMALLDATETIME NULL,
  5. CustomerName NVARCHAR(100) NOT NULL,
  6. TotalStarter INT NULL,
  7. TotalMainCourse INT NULL,
  8. TotalSoftBevarage INT NULL,
  9. TotalLiquer INT NULL,
  10. TotalDessert INT NULL
  11. )

This can be done using the following query.

  1. DECLARE @sExecuteCommand VARCHAR(250), --Keepa the command to be executed.
  2. @sColumns VARCHAR(150) --Keeps the columns to be included in the formula.
  3.  
  4. SET @sColumns = 'TotalStarter+TotalMainCourse+TotalSoftBevarage+TotalLiquer+TotalDessert+'
  5. SET @sExecuteCommand = 'ALTER TABLE FoodOrder ADD TotalOrder AS ' + SUBSTRING(@sColumns, 1, LEN(@sColumns)-1) -- Creating the computed column.
  6. EXEC (@sExecuteCommand)

Note that a cursor or a loop can be easily used to populate the variable “sColumns” with the columns required for the formula.

Hope this helps.

Monday, January 30, 2012

UPDATE with JOIN

If you need to update data of a table (DestinationTable) with data of another table (SourceTable) there are 3 ways you can get this done in SQL.

Method 1

This is the most common and simple way with using a sub query.





  1. UPDATE DestinationTable SET DestinationColumn =
  2.     (SELECT ValueColumn FROM SourceTable WHERE DestinationTable.MappingColumn = SourceTable.MappingColumn)




 

Method 2

This users the most common FROM clause to join the two tables as shown below.





  1. UPDATE DestinationTable SET DestinationColumn = SourceTable.ValueColumn
  2. FROM SourceTable
  3. WHERE DestinationTable.MappingColumn = SourceTable.MappingColumn




 

Method 3

Last method mentioned below uses the join clause to join both the tables to make the update happen properly.





  1. UPDATE DestinationTable SET DestinationColumn = SourceTable.ValueColumn
  2. FROM DestinationTable
  3. INNER JOIN SourceTable ON DestinationTable.MappingColumn = SourceTable.MappingColumn




 

Hope these helps.

Friday, January 27, 2012

Naracoorte Caves – Naracoorte South Australia

If you are a cave lover, there are many places Australia has to offer. Out of them one of the best is Naracoorte caves in South Australia. Inside the caves you will be able to see lime stones which took about 200 million years to form.

Stalactites – Are the ones hanging from above. Because they form from water dripping from above they tend to get points on them.

 20120127_17075020120127_170817

Stalagmites – Are formed on floor and start growing up with time.clip_image00220120127_16453020120127_164536

Columns – Are formed by one stalactite and stalagmite connecting after so many years.

 20120127_16574520120127_16425520120127_165836

It is good idea to plan and visit the caves bit early since you need time to have a look into the caves. They normally close at 5PM and the last tour starts around 4PM.

There is a visitor information centre in the Wonambi Fossil Centre so you can find out the interesting places in Naracoorte Caves National Park. Wet cave is a free attraction. When you purchase a ticket for a tour to visit Alexandra cave you will get free admittance to the Fossil enter and the miniature man made zoo.

Pram accessibility is not there when visiting caves, also you need to take care of your young children because they might need lot of assistance from you when inside the caves. Also supervise your children frequently since some of the Stalactites and Stalagmites are fragile and if they break one then thy may be destroying millions of years of natures’ work.

Car parking is free and plenty of sitting areas are there. Toilet facilities are there also is a restaurant so you can buy food if you need.

Address : Naracoorte Caves National Park, PO Box 134, Naracoorte SA 5271.

Phone : (+61 8) 8762 2340

EMail : naracoortecaves@sa.gov.au

Web : http://www.environment.sa.gov.au/naracoorte/Home

Map


View Larger Map

Wednesday, January 04, 2012

Deep Creek Conservation Park, South Australia

If you would love to enjoy scenery and wild life, a place you should definitely visit is Deep Creek conservation park in South Australia. It is located at the southern tip of the Fleurieu Peninsula.

It is always better to have a 4WD or an AWD but with a 2WD also in good weather you will be able to do most of the tracks without any major problems.


Map



View Larger Map