Archive for December, 2006

Essential Software for Windows Machine

This entry was originally posted on November 22, 2005. I made some modifications to it. Right now I am giving Google Reader a try. Therefore FeedDemon is not part of my essentials anymore.

I recently rebuilt my laptop. On my workstation, I have used a few things that do not come with Windows, like VIM, Firefox, SSH client, Desktop Search, RSS / Atom reader, etc. I have also did some customization settings change to suit my tastes and needs. I thought I would do this many more times in the future, so I prepared this list. I will update this post as I move along or remember things.

0. Save off setting files from the machine before rebuild. Currently I need to save _vimrc, SlickRun MagicWords, Oracle glogin.ini, tnsname.ora, sqlnet.ora, ldap.ora, favorites in my Firefox, registered Sql Servers and groups, opml files, sqlcmd initialization file, my work folders and files, and VPN certificate;
1. AVG Free Edition anti virus software
2. Enable ClearType for display, this is good especially if you have a flat monitor
3. Google Desktop search
4. Open up explorer and adjust the view options of folders: show all hidden files and folders, display full path in the address bar, unhide system files, use Windows classic display, enable QuickEdit for DOS window.
5. Firefox
6. PuTTY
7. Adobe Acrobat Reader
8. SlickRun
9. VIM
10. Put putty into vim executable folder, add that folder to system PATH variable so I can launch PuTTY and vi from anywhere. Associate txt and sql extension to VIM
11. Chinese Language Pack. This will be prompted when I visit a Chinese site in IE. Windows installation media is needed.
12. Flickr Uploadr
13. Microsoft Office. I don’t use Office personally, but I need to have it for my better half
14. ZiGuang for Chinese entry. See my post here for setup instructions.
15. 7Zip
16. Sql Server 2005 Developer edition and latest Sql Server Book on line
17. Cygwin
18. Disable Outlook new mail notification
19. ActiveState Perl
20. Toad for Oracle
21. ISO Recorder if CD-RW drive is present on the machine
22. CutePDF

Firefox customizations and extensions
1. adblock+
2. BugMeNot
3. coComment
4. Forecastfox
5. Google Notebook
6. Google Web Comments
7. Greasemonkey
8. IE View
9. Nuke Anything Enhanced
10. PDF Download
11. vimperator
12. FireFTP

Greasemonkey Scripts:
1. Flickr Titles + Descriptions Batch Tools
2. FlickrAllSizes+

So what software do you consider essential? Share that with me by commenting below.

Comments (11)

Discarded newsletter piece

Imagine you have a time machine at hand. Rewind back a few years, or decades, depending on where you are in your life, to the point when you were fresh out of university, got your first job, and ready to change the world. You were full of enthusiasm and ideas. You were still in touch with your college buddies. You shared what you saw, what was cool, what was dorky, etc., with them or your then girl/boy friend, if you had one. Life was really good and exciting.

But life grew confusing as time went by. Soon the first couple of weeks’ excitement was over. By now you had flipped through the employee handbook and checked out the section on salary increase and promotion. You may have even fancied a little promotion next year, because the leadership course you took in college and MBA books you’ve skimmed through told you to take charge and dream big. Pretty soon you realized that you need to run back and forth to your supervisor for questions and clarifications. Sometimes, when you got home after work, you mentally went through some things you did during the day and worried if you did the right thing or pissed off person(s) higher in the food chain. You could get upset because your brilliant ideas were shot down or not seriously discussed during all those meetings, where you were just a wannabe, with old-timer co-workers looking at you with suspicion and trying to gauge your caliber. You were learning your way of corporate culture and thought some things were stupid at times. Life, after all, was quite different from what you imagined while you were in the ivory tower of your university campus. By now you probably realized just how important the internship was during college, because it lets you have a real taste of corporate work life.

If you were fortunate, you may found a compassionate, wise gentleman or lady that could serve you as a mentor. You learned from him/her things that you should and should not do. You learned some history of why things were the way they were, therefore the proper context from where to formulate your next steps. You learned some not necessarily glamorous, but practical shortcuts that could get things done quickly and efficiently. You learned to take it easy, and life has ups and downs, and that is ok. In other words, you learned some best practice that can only be gained from living in the real world.

In my usual round-about manner, let me introduce you this week’s feature, Sql Server best practice site. Here, you will find tips, shortcuts and scripts directly from seasoned professionals. These are things people learned while in the trenches, therefore they are extra valuable. Nothing beats the lessons you learned after late night shifts, putting out fires and exhaustive research. These tools can give you information quickly, in a format that you understand. They help you resolve issues quickly and efficiently.

Note: The piece above was intended to be a column I wrote for a Sql Server newsletter, to which I contribute content as a volunteer every fortnight. I then realized it got a little too long, so I gave it up and decided to post it here instead.

Comments (2)

Executing sql scripts using command line tools

Sql Server 2005 has a command line tool named sqlcmd. MySQL has a command line tool named mysql. Oracle has a command line tool called sqlplus. They can all be used for interactive query processing and batch scripts processing. They do similar things, albeit in different ways. They are functionally equivalent.

For Sql Server 2005, when in interactive mode of sqlcmd, use

:r c:MyFolderMyScript.sql

to read and execute a script file. You may have to type

go

afterwards, if the last line of the script file does not end with the word go.

To use sqlcmd in batch mode, that is, to run a sql script and then get out, use:

sqlcmd -i c:MyFolderMyScript.sql -S MyServerName -E

Replace -E with -U LoginName if you use Sql authentication

For MySQL, while in interactive mode of mysql, use

. c:MyFolderMyScript.sql (on Windows)

Note there should be a backward slash right before the dot. In fact, please pay attention to all backward slashes in Windows directory names. Or

source ~/MyFolder/MyScript.sql (on *nix)

to run a script file.

For batch mode, use

mysql -h MyHost -u MyUser -t -p < ~/MyFolder/MyScript.sql

The -t is not necessary here, but it presents the results in table/grid format, therefore more readable.

In Oracle sqlplus, while in interactive mode, use

start c:MyFolderMyScript.sql (on Windows)

or

@ ~./MyFolder/MyScript.sql (on *nix)

Note that if the script file name has the .sql extension at the end, it is not necessary to type .sql. sqlplus assumes the .sql extension.

For batch mode, make sure you have exit as the last line of the script file, and run this

sqlplus MyUser@OracleSID @c:MyFolderMyScript.sql

Comments

desc is sp_columns in Sql Server

In Oracle and MySql, to get the column name and data type of a table, you can use:

desc MyTable

or

describe MyTable

The equivalent of desc in Sql Server is sp_columns. Therefore, run the command below will get similar results:

sp_columns MyTable

Comments (2)

读保罗-麦卡特尼的新闻有感

This entry expresses my own opinion. It could be interpreted by some as political. Read it at your own risk :)

Paul McCartney and Heather Mills McCartney are in tabloid headlines lately. Their high profile divorce has captured the imagination of many people, especially with Heather’s alleged allegation of abuse and account of her exploits prior to their marriage. It appeared that Sir Paul ignored the good council of his daughter Stella and made a really costly mistake. That reminded me some other news that they made awhile ago. That is, they vowed they would never step on Chinese soil because of animal cruelty in China.

I actually felt a little offended by their comments. Not that I would deny the existence of animal cruelty. It does exist, it is appalling, it is gruesome, and it needs to be condemned. In fact, it is one of many, many issues that exist in China that need to be addressed. (The same can be said about many other countries, but that does not make it right.) Nor do I object the fact that people express their opinions. Furthermore, I do not wish to promote political-correctness where people have to express their thoughts in coded language. The thing that I object to is their condescending attitude and prejudice: look at me, I am so good and have such high moral values, you are so bad and disgusting, I do not want to have anything to do with you. When people have this attitude, no matter how noble their objectives, it can only alienate the public at large (because only a very small percentage are guilty as charged in any culture) and have a negative effect to the cause they are promoting.

Allow me to digress here a little, because it actually brings a good question on how to deal with outside opinions.

I think there is no need to be defensive on an objective outsider’s account and analysis of one’s own culture and society. Rather, it provides a good vantage point for people within to reflect on many assumptions and customs that they take for granted, learn from it, and make appropriate adjustment for improvement. This is easily said than done, and different people have different views on what is objective and what is not. But ultimately, I think that is the right attitude to deal with objective outside opinions.

On the other hand, I think it is sometimes appropriate to ignore comments and opinions from outside. In some cases, it is also important to put out a different point of view to counter them, if the stakes are high enough to warrant such act. This is especially true for developing countries. The western mainstream media, especially ones from the US, are controlled by surprisingly few corporations. Because the economic power it has, those media outlets can spread their views easily across the globe. While doing that, they also get to define the context of issues at hand, which is just as important. In the US, some reporting and opinions of mainstream print and TV media can be skewed and grossly misleading: the pre-Iraqi war and Middle East reporting in general are perfect examples.

Therefore, it is important to take outside news/opinions/comments with a grain of salt. If it is good and objective, accept it and learn from it, and don’t be defensive about it. If it is wrong and misleading, analyze the stake first and then decide for a right response. Sometimes US mainstream media can make the victim look bad for making a fuss out of what it calls a small offense, because public relation from the developing world is usually not as slick as western world, due to language, cultural, and economic reasons. So a creative response and sometimes simply ignoring it may not be a bad idea. But if the stakes are high, it is important to put out a different view to counter it.

PS. To be fair, third world countries, including China, lack much, much more in press and personal freedom and have a lot to learn from the west in this area and many others, but that does not mean propaganda and government manipulation does not exist in a democratic society (paying off newspaper columnists, selective leaking or suppressing intel for political purposes, passing propaganda video as news source, planting questions in news conferences, etc., the list goes on and on). I guess my point is that we need to learn the good things from others. But equally important, we also need to learn from the mistakes of others. Don’t let your judgment colored by blind admiration. Be pragmatic and realistic. I say this from personal experience, because I was a blind admirer of everything West/American for a long time.

Comments (2)

Some autumn and winter 2006 pictures

Fall colors at Brookfield Zoo

20061112 063

20061112 075

Fall colors at Morton Arboretum

20061112 049

20061112 062

Snow, Oak Park, Illinois

20061212 075

20061212 066

Not sure what the red tree fruit/nut is called

20061212 068

The old way of farm life on display at a children and craft fair in a town north of Waco, Texas, during Thanksgiving. Some of it is pretty similar to what I experienced when I was little.

Ploughing demonstration

20061212 050

Mill house

20061212 033

The forge

20061212 035

A nice little river in a forest preserve near Dallas area during Thanksgiving

20061212 015

Comments

Troubleshoot Sql Server cluster and ClusterRecovery

With some San disk configuration and drive letter changes, a two-node 64-bit Sql Server 2005 cluster on Windows 2003 boxes would not start, as evidenced in Cluster Administrator. Here are some errors in Event Viewer:

Sql Server application error in Event Viewer
[sqsrvres] OnlineThread: Error 435 bringing resource online.

Sql Server Agent
[sqagtres] CheckServiceAlive: QueryServiceStatus failed (status 6).

Some research didn’t turn out anything. Since this issue was fairly urgent, I called Microsoft PSS and put in an urgent request. I was connected to a very nice support person out of Bangalore, India.

We then tried to start Sql Server from services applet on the local active node, to no avail. Next we looked at Sql Server startup parameters, located at HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\Parameters. It turned out that those parameters are pointing to the wrong drive, because I know Master database is not there.

So I manually changed the drive letter, then went back to Cluster Administrator to start Sql Server. It failed again. And the odd thing was, the startup parameter would revert the drive letters back to the wrong ones.

So support supplied me with a tool called ClusterRecovery.exe. And we were able to use this to make the registry drive letter change stick. Here is what we did:

1. Connect to Sql virtual server name (not the underlying Windows cluster virtual name);
2. Pick Restore cluster resource checkpoints;
3. Click Next, then pick Sql Server from the drop-down;
4. Proceed with registry change;
5. Do the restore on ClusterRecovery tool.

We also changed the drive letters for Sql Server agent, using the same method, at this registry location:
HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL.1\SQLServerAgent

ClusterRecovery.exe is available for free download.

Regarding PSS, in some cases I found that I actually know more than Microsoft support guys. To me, the most valuable thing is it provides a sounding board. Usually, when you are calling support, you are likely to be in a stressed mode. A knowledgeable person acting as a sounding board is invaluable, since s/he can remind you things you may have overlooked, provide you with a new angle to look at things. You are speaking to a person at your level with a language you both understand, instead of having to dumb things down for your manager, who, depending on his/her personality, may actually make things worse. Through this kind of peer to peer sharing and brainstorming, a solution can usually come out. It may not be a silver bullet all the time. But when it is, that can really make your day. So thanks, Jayaraj, if you are reading this.

I also like PSS’s EasyAssist, which is a screen-sharing tool. It allows both you and the support person to look at things together, which is invaluable in my opinion. Sometimes I found PSS’s request of log files tedious, because I have looked at them already and I’d rather do the screen sharing so we can look at them together. But I understand that for less experienced professionals, that is necessary. Whether you get a nice support person depends totally on your luck.

Hope this will help somebody. If it helps you and you feel obliged, do a donation through my email at PayPal. I promise I will put it into good use :)

Update: My blogging buddy and fellow PASS volunteer K. Brian Kelley commented here, that points to a kb article that describe this issue. Thanks a lot Brian!

Comments (1)

Quick script to rebuild full text search

Below is the script I learned while in Seattle attending PASS conference. Some guys from Microsoft helped me to rebuild full text index on some SharePoint databases I manage.

select * from sys.fulltext_catalogs

sp_configure ’show adv’,0
reconfigure

– Get the fulltext catalog name to rebuild
select object_name(object_id), * from sys.fulltext_indexes

select * from docs where 1=0

select * from docs where contains(*,’SomeString’)

select extension,
count(*) from docs where extension <> ‘’ group by extension

distinct extension is not null contains(*,’SomeString’)

select count(*) from docs

select * from master.dbo.sysfiles

–Rebuild fulltext catalog and index
ALTER FULLTEXT CATALOG ix_MyFullText REBUILD with accent_sensitivity=on

select fulltextcatalogproperty(’ix_Catalog’, ‘populatestatus’)
select fulltextcatalogproperty(’ix_Catalog’, ‘itemcount’)

Comments (1)