Friday, January 25, 2013

Lock Windows

If you wanted to lock your Windows using a batch file it can be achieved using the following command.

rundll32.exe user32.dll, LockWorkStation

This will be handy if you need to lock your computer after a certain scheduled action. Simply place this in a bat file, and schedule the bat file to be run to get the computer locked.

I tried this on Windows 7.

Monday, January 21, 2013

Enabling Hibernate in Windows 8

If you have start using Microsoft’s latest Personal Computer (PC) Operating System (OS) Windows 8, by now you may have found it is different in some ways to it’s predecessors. One feature I am heavily using in Windows was again missing after installing this version of Windows, which is the hibernation feature.

image

So if you like hibernation shown on your power menu try doing the following.

1. Move your mouse cursor to the right side of your screen to activate the quick access menu and click on Settings and then on Control Panel.

image

image

2. Then select “System and Security”.

image

3. Now select Power Options.

image

4. From the left hand navigation menu select “Choose what the power button does” or “Choose what closing the lid does”.

image

5. Now on system settings screen you need to click on “Change settings that are currently unavailable” to modify the disabled options.

image

6. Scroll down to Shutdown settings and check the box named Hibernate and click Save Changes button.

image

Now if you look at the options available in your power menu Hibernate will also be part of it.

image

If this does not bring hibernation back, please try the following as well.

1. From the power options screen select “Change plan settings” of the active plan.

image

2. Then select “Change advanced power settings”.

image

3. Now click on “Change settings that are currently unavailable”. This will list down all the features available in the system. Scroll down and expand Sleep –> Allow hybrid sleep and turn on hibernation as you want.

image

image

 

With these changes the “Hibernate” option should start appearing in your Power options menu.

Sunday, January 20, 2013

Aviation Museum – Port Adelaide South Australia

If you are an aviation fan you might enjoy a visit to South Australian Aviation Museum. They do have some aircrafts on display where you can get on board to have a look without a passport. This is a non profit organization managed by aviation enthusiasts. There is also a shop for you to buy related things such as model aircrafts and magazines.

Entry tickets are priced at $9 per adult and free parking is available onsite.

Address: 66 Lipson Street, Port Adelaide, SA 5015
Phone: 08 8240 1230
EMail: saam@adam.com.au
Web: http://www.saam.org.au/

Map


View Larger Map

Saturday, January 05, 2013

Marble Hill Cherry Farm – Ashton South Australia

Like to pick your own Cherries, then good place to visit is the Marble Hill Cherry farm located in Ashton SA 5137. This family operated farm is usually a pick your own farm meaning most of their produce is picked and bought by people who visit the farm in Cherry season like us.

Ashton is hill country so on your way to the farm you will encounter great scenery, also be careful and drive safe since some roads are windy and narrow.

Cherry season is a short 2 month period normally from December to January and depending on the number of people visiting Cherries might finish even before the season end, so always call or check their web site before going.

Cherry orchard has uneven ground (slope), so make sure to wear something you can easily walk in slopes and grass. Hats are also suggested. If you are travelling with young children and like to stay behind, you can stay in the scenic shed. It is having plenty of chairs. The management is also very kind, they provide free cool drinking water and ice cream for a small amount. If you like to continue cherry picking with young children then a child carrier sling is suggested.

Normally entrance fee is $ 5 and they will provide a bucket as the container to hold the Cherries you pick. Whatever amount of Cherries you pick should be payed for ($ 8 per Kilo). On your entry it is better to check the price since it change every year. Since Cherries can be kept fresh for about 2 weeks in fridge make sure to pick only the amount you want.

Address: Marble Hill Cherries, 25 Marble Hill Rd, Ashton, SA 5137.
Phone: (08) 8390 0327, 04 1136 1651
EMail: marblehillcherries@cherriessa.com.au
Web: http://www.marblehillcherries.com

Map


View Larger Map

Sunday, November 25, 2012

SQL Truncate vs. Delete

By now as you know, in this post I am going to discuss about two SQL commands we use regularly to clear data in our tables.

Usage





  1. DELETE FROM TABLENAME
  2. TRUNCATE TABLE TABLENAME




Even though they do a similar thing, there are some differences which makes them unique commands.

 

DELETE

TRUNCATE

1. Considered as Data Mining Language (DML) statement. Considered as Data Definition Language (DDL) statement.
2. Can be used to delete all or part of data in a table. Will delete all the data in a table.
3. Will log the actions. There will be no logging on record deletion.
4. Will use more locks. Will use fewer locks.
5. Will use more resources. Will use less resources.
6. Slow. Fast.
7. Will not reset the identity seed. Will reset the identity seed to 0.
8. Can be used to delete data in tables having relationships. Cannot use in tables having relationships.
9. Can be used in tables involved in log shipping or replication. Cannot be used in tables involved in log shipping or replication.
10. Transaction can be rolled back. No rollback.
11. Table may keep the empty pages. Can be released by running, SHRINKDATABASE (Database Name). Data pages related to the table will be de allocated and returned to the system.
12. Related Triggers are fired. Triggers are not fired.

 

If you used DELETE to fully remove all the records, you can reset the identity value by running the following command.





  1. DBCC CHECKIDENT (TABLENAME, RESEED, 0)




If you do have some rows left in table, simply replace 0 with the last identity column value. For example if you put 5 instead of 0 then the next record inserted into the table will have an identity column value of 6.

If you jus need to check the current identity value just use the following command.





  1. DBCC CHECKIDENT (TABLENAME, NORESEED)




Saturday, November 10, 2012

Beerenberg Strawberry Farm – Hahndorf South Australia

If you like Strawberries and would like to pick your own, then there is a good place you can do it in Hahndorf South Australia.

It is called Beerenberg Strawberry farm, located on the Mount Barker road. If you are planning to visit them to pick your own strawberries you need to visit them from October to May which is the Strawberry season. Else you can buy their produce from the shop.

Normally they are open everyday except Christmas day from 9:00AM to 04:00PM. Anyway it is always good idea to give them a call before going.

There is enough parking on site and there will be a helper on busy days.

Once you are there you can visit the shop to get permission to enter the patch. When I was there entry was $ 3 per person. They will also provide containers to bring the Strawberries you pick. Remember to pick whatever amount of Strawberries you would like to buy. Normally you can keep them from few days to about 10 days in fridge (obviously you can keep bit more days than this but then they wont be tasting fresh). Once you have enough Strawberries picked you can bring them back to the shop where they will weigh it, so you can pay. While I was there they sold a Kilo of Strawberry for $ 9, but the price always changes from season to season, so it is always best to check the price they are selling before heading to the Strawberry patch.

If you are travelling with young children, I do not recommend a pram since the ride will be bumpy, best is to use a child carrier sling.

Address: Beerenberg Strawberry Farm,
Mount Barker Road Hahndorf,
South Australia, 5245
Phone:
+61 8 8388 7272
Fax: +61 8 8388 1108
Email: admin@beerenberg.com.au
Web: http://www.beerenberg.com.au/

Map


View Larger Map

Sunday, September 30, 2012

Importing Data into SQL

If you need to import data from a file, this can be achieved by using SQL Bulk Insert command. Recently I did use this method to import some 500 000 data from few comma separated value (CSV) files and thought to share it with you. What you need to remember is, if you are importing data from more than one file the data should have the same format through out the files.

This is a sample set of data I imported into my table from the file named File1.csv.

Login,Name,Date,Result,Pass

U0001,Roman Silva,1/10/2010 17:23,100,TRUE

U0002,Anthony Don,28/09/2010 10:01,70,TRUE

U0003,Saman Perera,16/09/2010 11:31,90,TRUE

U0004,Silvia Raz,26/09/2010 22:11,40,FALSE

U0005,Rebecca Maine,18/09/2010 11:30,100,TRUE

I used the following script to create a temporary table for my imported data.

  1. SET ANSI_NULLS ON
  2. GO
  3.  
  4. SET QUOTED_IDENTIFIER ON
  5. GO
  6.  
  7. CREATE TABLE [dbo].[TABLENAME_ImportedData](
  8.     [LoginId] [NVARCHAR](50) NOT NULL,
  9.     [Name] [NVARCHAR](200) NULL,
  10.     [Date] [DATETIME] NULL,
  11.     [Result] [INT] NULL,
  12.     [Pass] [NVARCHAR](8) NULL
  13. ) ON [PRIMARY]
  14.  
  15. GO

To fetch data from the file I used the following script.

  1. BULK INSERT [TABLENAME_ImportedData]
  2. FROM 'D:\DataFiles\File1.csv'
  3. WITH (
  4.          FIELDTERMINATOR =',', -- Since my columns are seperated using commas (,).
  5.          ROWTERMINATOR ='\n',  -- Since each data row is in its own line.
  6.          FIRSTROW = 2          -- Since my first row is having column names. Please note FIRSTROW is not recommended to skip the column names.
  7.       )

While running the script I faced an issue with the date since my server was set to US English as the default language. In US English the dates should be in MDY format. So I had 3 choices, either to change the date formats on my data files, change the server default language to another language which has its date format as DMY or change the date format of the server. I used the easy way to change the date format of the server by running  the following command.

  1. SET DATEFORMAT dmy

If you like to change SQL server default language and need help please read my article on that.