Skip to main content

Posts

Brand new year - 2015

2015 with Golden Ratio

tablediff command line utility in SQL Server

Above tablediff utility is very useful for comparing tables.It is not only tells us which records / columns are different but can also generate a SQL script to update the second table to make it the same as the first table. You have to navigate to following path the use this utility SELECT 'C:\Program Files\Microsoft SQL Server\100\COM> Then type command ; tablediff –? Then it shows all the options as follows   But only limitation is you could compare one table at a time. Even though you can do some interesting work to overcome this. That is Just go to the SQL sever and type following command execute it. So it will generate the script for all the table. Then you can add it into .bat file. SELECT 'C:\Program Files\Microsoft SQL Server\100\COM>tablediff -sourceserver "SourceDBName" -sourcedatabase "T1" -sourcetable ' + '"' + name +'" ' + '-destinationserver "DestinationDBName" -destinationdataba...

SQLCMD command line utility

To run multiple external scripts do as follows; Suppose you are having following scripts in a folder. c:\scripts\script1.sql, c:\scripts\script1.sql If you add the following example to .bat file ,it runs those scripts from the command line and outputs the queries and results to a text file located at C:\Result.txt. sqlcmd -S ERANGA-PC\SQLEXPRESS -d T1 -U sa -P Qwer1234 -i c:\scripts\script1.sql -i c:\scripts\script1.sql –o c:\scripts\Result.sql

Recurrent Work–Automate them

Problem Sometimes we do some recurrent works those can be automated. Few months back in a integration of two project I had to create multiple database scripts to merge those two. There are more than twenty scripts.Initially I run those one by one and it took long time to create the DB. Mistake We don’t care to automate those recurrent work .Just Do at the point you need. Once you get to know its recurrent you will regret I could have automate this. Lesson Learned By automating recurrent works [Those can automate] you can save your time

SQLCMD command line utility

Recently I work with SQLCMD utility and it is quite interesting. You can enable it in your Management studio as follows; Then you can make use color coding and syntax highlighting as well . Other than this ,you can enable this SQLCMD mode in your normal command line by setting path variable to binn folder as following example C:\Program Files\Microsoft SQL Server\100\DTS\Binn\ Then just open command line and then type this command.It will show the option available; -sqlcmd –? To connect to a database and query for data sqlcmd -S ERANGA-PC\SQLEXPRESS -d T1 -U sa -P Qwer1234 –q “Select * from Student”

Twenty Ten Last Day

Today is the last day of this year..This will be the last post in this year . Lot of things happened in this year and already every things has added to our life as a experience. For everybody……         HAPPY NEW YEAR!!!!!!!!!!!!!

Importance of good user message

Problem Company 1 Dear Valued Customer,Your Mobile invoice value for [date] is Rs[Amount] & the total outstanding value at date is Rs[Amount]. Thank you. Our record indicate an overdue of Rs.[][date] pls settle the same by date to enjoy uninterrupted services.Pls ignore if settled. Company 2 Dear Valued customer,Your bill dated date is now due.Please make payment.if already settled pls ignore this sms. Given messages are received from two different telecom company in Sri Lanka when there is a due payment . Mistake The way messages has presented is different .In company 1 first reminder message sends very polite manner. but it’s second message is not polite it directly gives the message . But message is informative but company 2 message is very polite and short but it s not informative.When reading, user gets two different impression over the message. Lesson Learned So good message should polite,short and informative.

Appreciation

Today I got this touching email: One young academically excellent person went to apply for a managerial position in a big company. He passed the first interview, the director did the last interview, made the last decision. The director discovered from the CV,  that the youth's academic result is excellent all the way, from the secondary school until the postgraduate research, never has a year he did not score. The director asked, "Did you obtain any scholarship in school?" and the youth answered "none". The director asked, " Is it your father pay for your school fees?" the youth answered, my father passed away when I was one year old, it is my mother who paid for my school fees. The director asked, " Where did your mother worked?" the youth answered, my mother worked as cloth cleaner. The director requested the youth to show his hand, the youth showed a pair of hand that is smooth and perfect to the ...

Chain of Responsibility Pattern

This pattern I used for handling scenario as follows; Applying permission on user to view some data is based on many criteria and those are having a sequence. By Appling this chain of responsibility pattern I could able to arrange the code nice manner , very easy to add new criteria as well as change the sequence.

Organized well

In your desktop where is your taskbar? Most of them keep it as default . That is in bottom of the screen like this. Till few months back I also kept as that manner. But now I have positioned it right side of the screen. By keeping in this position its is very comfortable to access the list . High number of items can be arranged in this position in a very organized manner. If you are using wide screen, this is the effective position to use the maximum use of the screen. Following screen gives idea of comparison of the positions. Other than those when positioning the task bar we should concern about followings; Continually remove unwanted items, otherwise cant directly access the what we want so it will be a time consuming task. Arrange the width of the task bar up to user preference. Enjoy the right side arrangement of the taskbar.

Before You Refactor

Refactoring need to be done by every programmer and it leads to have a maintainable code base.Rajith Attapattu has highlighted very good points when doing refactoring The best approach for restructuring starts by taking stock of the existing codebase and the tests written against that code. Avoid the temptation to rewrite everything. Many incremental changes are better than one massive change. Many incremental changes are better than one massive change. New technology is an insufficient reason to refactor. New technology is an insufficient reason to refactor. Remember that humans make mistakes. Other than above, good practices can be found in here .

97 Things Every Programmer Should Know

Some sections of above book I read few months back and today I got a thought to read it again. There are more than 97 things programmer should know but this is great collection and good prioritized list to follow. No need to read it from top to bottom , can switch to any topic as we like. . Also it’s proud to find one author from Sri Lanka who is Rajith Attapattu

Ship It Review -2

You need to focus following three area to built up a great product and ship it successfully ; Techniques Infrastructure Process The book highlights importance of following areas comes under the tools and infrastructure, Manage Assets , Script Your Build , Build Automatically , Track Issues, Track Features, Use a Testing Harness , On Choosing Tools ,When Not to Experiment. These factors lead  for building a good infrastructure by saving time, and enhancing effectiveness.In the beginning of the chapter two ,it gives nice quote by John Carmack. . . the cost of adding a feature isn’t just the time it takes to code it. The cost also includes the addition of an obstacle to future expansion.. . . the trick is to pick the features that don’t fight each other. Shortly the code should be according to the Open close principle .

Rubber Ducking

Actually this is great concept we can used for improve our coding and also to find the missing areas in our scenario. Find More Concept : Place a rubber duck on your monitor and describe your problems to it. There's something magical about stating your problems aloud that makes the solution more clear.

The transaction is in doubt

Sometimes you may get this error when you use transaction scope . The transaction is in doubt I also got this error recently and able to find the reason for it. That is because of the some of the readers had not properly disposed. Actually in this case you can use Using keyword to overcome this. Exception : System.Transactions.TransactionInDoubtException was unhandled by user code Message="The transaction is in doubt." Solution : using (reader) { }

Ship It Review -1

This books has been described Habits in interesting manner. Following story took from it and the story shows how we should go for a decision rather considering everybody doing it or becuse of we have already done it. Story: Did you hear the story of the woman who always cooked ham by cutting off and discarding a third of it first? When asked why, she said that was how her mother always cooked hams. When asked, her mother said that was how her mother had always cooked. They finally confronted Grandma, who admitted that when she was young, she didn’t have a pan big enough for an entire ham, so she always just cut the end off, and it became a habit.