Thursday, May 27, 2010

Do not Take Driving Test at Marrickville RTA

Do not take driving test at Marrickville RTA, NSW.
I booked for a test a while ago. Then I check online for test route information. Unfortunately, I found that this RTA has a very bad reputation on some discussion forums. Generally, people who can have an easy pass will fail there, and some one even failed 5 time there before got a pass at another RTA. But I have booked there; so I have to wish myself good luck.
I didn't have a good luck yesterday. Failed because of two minor problems. 1. Didn't have enough observation at cross road. I understand that is my problem for long. I just don't want to shake my head like some drug addicted. When I passed the driving test and got license in Hong Kong (that was a one-shot success, and my driving skill was much much worse), the test officer told me I should improve on that. 2.Speeding. This is really ridiculous. I was constantly driving under 40km/s on a road with limit 60km/s. Yet I was called speeding. And his point is I didn't keep 3-sec distance to the car ahead. Come on, other cars kept on sneaking in my lane as I was slow. If I am driving under 30km/s, I am a hazard on the road and that's the concern.
After this experience, I believe that RTA is a money-making machine. They have been taking millions and millions of fine money from innocent people; and they are charging excessive test fees by just simply fail testers again and again. Better yet, the road is never a safe and convenient place for us.

Tuesday, May 25, 2010

Listening face

Watching Master Chef recently, and found one of the commercials is really hilarious.
Here is the link to the Ad on Youtube.
Here is the subscipt:
I love to multi-task, and I love to listen. And if I have no woman to listen to, I practise my listening face: "I love to listen with power. I love to hear of the problems of your friends. Tell me more…"

Is listening (or listening face) really an essential attribute of a perfect man?

Monday, May 24, 2010

SQL updatet with inner join

SQL update statement doesn't like to include an inner join clause -- although it is doable with a little modification. (Goo it with the keywords.) -- it definitely doesn't like to include an inner join and an aggregate clause at the same time. For example, the following does NOT work.
Update tableA
Set Flag = 1
From tableA
Inner Join tableB on tableA.ID = tableB.ID
Where ...
Group By tableB.ID

In this case, the option left is to use nested select statement.

Friday, May 21, 2010

Finally my Discrete Math class pay off

I am writing a long and complicated stored procedure. Basically it is like
"if A is true, then
  SELECT blabla FROM bla WHERE (B = true)
otherwise,
  SELECT blabla FROM bla WHERE (B = false)"

I don't want to write CASE WHEN; and I don't want to repeat the common SELECT stuff. So this is what I do:
"SELECT blabla FROM bla WHERE (A = false OR B = true)"
 This is because "if X then Y" is logically equivalent to "not X or Y"

刮骨疗毒

话说,关羽手臂被毒箭射~~~中。华佗为其刮骨疗毒。关羽问华佗:“大~~~夫,这次手术的成功性有多大?”华佗说:“我已经做过99次同样的手术了。”关羽道:“那我就放心了。相信你会成功。”华佗道:“谢谢谢谢!我想我也该成功一次了啊!

话说,关羽手臂被毒箭射~~~中。华佗为其刮骨疗毒。关羽突然跑了。刘备见状,问关羽:“你跑什么啊?”关羽道:“刚才华佗的徒弟说‘勇敢点!别害怕!这个手术很容易!’”刘备:“容易你怕什么?”关羽道:“但是这句话是华佗的徒弟说给华佗听的啊,大哥!”

话说,关羽手臂被毒箭射~~~中。华佗为其刮骨疗毒。华佗安慰关羽说:“别怕,一点都不痛的,一会就好……”关羽打断道:“呵呵!别说了,我以前也做过两年郎中的!

话说,关羽手臂被毒箭射~~~中。华佗为其刮骨疗毒。当华佗拿出刀子,关羽害怕了,不让华佗动手。于是,华佗叫人倒了一杯酒给关羽,喝后,问关羽:“有勇气了吗?现在还怕吗?”关羽道:“还有一点怕。”于是,又给关羽喝了一杯。关羽还是害怕。就这样不停的喝了几十杯。华佗又问:“现在是不是勇气十足?”只见关羽昂首挺胸,跳到了桌子上,大声叫道:“我倒要看看,谁xxxx敢动我的手臂!!”

Thursday, May 20, 2010

A test on scheduled SSIS job

I have create an SSIS package that monitors an FTP and imports incoming data sets as flat files to the SQL server. (BTW, importing directly to an SQL destination is much faster than importing through ADO connection.Guess why?) It is deployed as a scheduled job on the server. The problem is: what should be schedule interval -- given that the job should be run as often as possible while the timespan to run an importing is indefinite.

I was afraid that the scheduled job would be pre-empted when a new schedule starts. That would cause a disaster -- 'cause no one knows what will happen when importing is stopped in the middle. So I conduct a test: I create a 2-min importing job, but schedule it as run every 1 minute. The result is: the next schedule will start only when the current one finishes. Mercy.

Wednesday, May 12, 2010

Wednesday, May 5, 2010

Different Options for Importing Data into SQL Server

ProblemMoving data into SQL Server is something that most DBAs or Developers are faced with probably on a daily basis.  One simple way of doing this is by using the Import / Export wizard, but along with this option there are several other ways of loading data into SQL Server tables. Another common technique would be to use either DTS (SQL 2000) or SSIS (SQL 2005).  In this tip we take a look at some of these other options for importing data into SQL Server.
SolutionIn addition to using the Import / Export wizards and/or DTS or SSIS to move data into SQL Server there are also a few other options for doing this that are built into SQL Server.  Some these other options include bcp, BULK INSERT, OPENROWSET as well as others.  The following examples show you some of these different options for importing data and how you can use some of these inline with your T-SQL code as well as others that can be run from the command line.

BCP
This is one of the options that is mostly widely used.  One reason for this is that it has been around for awhile, so DBAs have come quite familiar with this command.  This command allows you to both import and export data, but is primarily used for text data formats.  In addition, this command is generally run from a Windows command prompt, but could also be called from a stored procedure by using xp_cmdshell or called from a DTS or SSIS package.
Here is a simple command for importing data from file C:\ImportData.txt into table dbo.ImportTest.
bcp dbo.ImportTest in 'C:\ImportData.txt' -T -SserverName\instanceName
For more information about bcp click here.

BULK INSERT
This command is a T-SQL command that allows you to import data directly from within SQL Server by using T-SQL.  This command imports data from file C:\ImportData.txt into table dbo.ImportTest.
BULK INSERT dbo.ImportTest 
FROM 'C:\ImportData.txt' 
WITH ( FIELDTERMINATOR =',', FIRSTROW = 2 )
For more information about BULK INSERT click here.

OPENROWSET
This command is a T-SQL command that allows you to query data from other data sources directly from within SQL Server.  By using this command along with an INSERT INTO command we can load data from the specified data source into a SQL Server table.
This command will pull in all data from worksheet [Sheet1$]. By using the INSERT INTO command you can insert the query results into table dbo.ImportTest.
INSERT INTO dbo.ImportTest 
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=C:\ImportData.xls', [Sheet1$])
Here is another example where data is pulled from worksheet [Sheet1$] by using a SELECT * FROM command. Again, by using the INSERT INTO command you can insert the query results into table dbo.ImportTest.   The query can be any valid SQL query, so you can filter the columns and rows by using this option.
INSERT INTO dbo.ImportTest 
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=C:\ImportData.xls', 'SELECT * FROM [Sheet1$]')
For more information about OPENROWSET click here.

OPENDATASOURCE
This command is a T-SQL command that allows you to query data from other data sources directly from within SQL Server. This is similar to the OPENROWSET command.
INSERT INTO dbo.ImportTest 
SELECT * FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0', 
'Data Source=C:\ImportData.xls;Extended Properties=Excel 8.0')...[Sheet1$]
For more information about OPENDATASOURCE click here.

OPENQUERY
Another option is OPENQUERY.  This is another command that allows you to issue a T-SQL command to select data and again with the INSERT INTO option we can load data into our table.  There are two steps with this process, first a linked server is setup and then second the query is issued using the OPENQUERY command.  This option allow you to filter the columns and rows by the query that is issued against your linked data source.
EXEC sp_addlinkedserver 'ImportData', 
   'Jet 4.0', 'Microsoft.Jet.OLEDB.4.0', 
   'C:\ImportData.xls', 
   NULL, 
   'Excel 8.0' 
GO
INSERT INTO dbo.ImportTest 
SELECT * 
FROM OPENQUERY(ImportData, 'SELECT * FROM [Sheet1$]')
For more information about OPENQUERY click here.

Linked Servers
Here is yet another option with setting up a linked server and then issuing a straight SQL statement against the linked server.  This again has two steps, first the linked server is setup and secondly a SQL command is issued against the linked data source.
EXEC sp_addlinkedserver 'ImportData', 
   'Jet 4.0', 'Microsoft.Jet.OLEDB.4.0', 
   'C:\ImportData.xls', 
   NULL, 
   'Excel 8.0' 
GO
INSERT INTO dbo.ImportTest 
SELECT * FROM ImportData...Sheet1$
For more information about Linked Servers click here.
As you can see right out of the box SQL Server offers many ways of importing data into SQL Server.  Take a look at these different options to see what satisfies your database requirements.

Monday, May 3, 2010

希腊债务问题

世界金融两大市场上,美国在批斗高盛,欧洲在为希腊头疼。其中可能有些联系——高盛可能在希腊的债务危机中扮演了可以的角色。不过话说回来,别人再如何推波助澜也只是因为希腊自己挖了个坑跳进去了而已。
这个坑叫做奥运会。
在2004奥运会财政报告会上,希腊的财长曾很明确表示“The cost of the Athens 2004 Olympic Games substantially overshot the budget”,虽然可以辩称,奥运会是项长远的投资,对将来都是很有益的。但是这确确实实是个大坑。
算笔账。希腊的年收入大约100B,正常的财政支出大概能打个平手。奥运会一来,政府要拿出10B来做建设。这是表面的支出。为了社会的稳定和奥运期间的礼仪安全,需要安定民心。于是就大手一挥,给大家加工资加福利。老百姓一开心,当然就努力工作、安居乐业了。这样一来,政府的支出大了,即使有些赞助,那也还得借债。顺便提一句,希腊的家当也就和台湾一个水平。比台湾还不如的是,希腊主要靠农产品和旅游赚钱,工业和金融比较落后。
一晃几年过去了。这几年恰恰是多灾多难的几年。 债务涨了,投资亏了,出口收入低了,老百姓的福利还没法往下压。希腊终于挺不住了。

Saturday, May 1, 2010

追星族

上个星期从电视上认识了一个人,叫做Justin Bieber (简称JB)。据说是个加拿大的小男生。他唱歌的片段被他妈妈放上youtube,被星探发现,然后就火了。他来澳洲巡回,那些无知无畏的小女生,日夜兼程,昼夜等待就为了见他一面。有几个小姑娘还受伤了。最后警方看不下去了,鉴于纽约发生过类似问题,就决定以安全为由,取消了见面会。让JB去电视台录音棚里露脸了。小女生们一路的抗议啊。
开始还以为我的审美有问题,问了下太太,她觉得JB同学实在长得很普通,没有传说中的那么酷、那么Cute。唱歌么,也就一般,小男孩变声都没完全,怎么可能好听。他的歌也就口水而已,就听到反反复复的“baby baby”,其他好像就没有了。当然,他能红肯定也是有道理的,但凭实力,我觉得比中国的偶像李宇春差着好多截。
JB能这么红,跟小女孩们的心理空虚和头脑简单是分不开的。看看这些年的欧美乐坛,好久都没有一个让少女痴迷的男性偶像歌手出现了。90后乃至00后在追星方面嗷嗷待哺了很久了。所以JB一出现就可以让一张毫无内涵的专辑可以在iTune上卖这么贵。
话分两头,那些无知少女的父母也实在是有问题,自己的女儿品味这么低也就算了。让她们为了追星可以露宿街头真的是过分了。想当年虽然所有的女生都痴迷小虎队,但是大多都非常理智的。果然时代不同观念不同了。