Saturday, September 27, 2008

Set nocount on

Anyone know what is "set nocount on" ?
Its function to set the message from query result to off.

example:

select * from tabelA

Usually, come out the message besides the results, such as below:

(xx row(s) affected)

You use "Set nocount on" to make the message disappears. Depends on your needs. Sometimes, you use it to decrease the server peformance, that after displaying the result of the query, it may give you the message around the query results. For your concern, the error message still be display.

Base on my experience, I use "set nocount on" in my Store Procedure.The purpose is to lighten my Store Procedure performance that it decreased the server works to give the message to its caller.

Can you imagine when your Store Procedure need to insert a lots of records one by one. It may result one message every success inserted record. Plus, other message if you have select queyr in your Store Procedure.

Have a try and i hope it will useful for you.

Have a nice day

Left vs Right Join in SQL Language

We know Left and Right Join in Sql Server. Do you know the differences between them ??
I will try to explain the difference between them and the tips from me in the usage.

Left Join, it use to join between 2 table which the left one will be display all records even there is no match record with the right one. Record with no match field partner will be display Null

The same for Right Join, we use it to join between 2 table and the right one will be display all records even there is no match record with the left one. Record with no match field partner will be display Null.

Sound difficult to understand with out the sample do you ?

Example:
Table A comes with Nim and Nama field ( have 3 records )
Tablel B comes with Nim and NamaMatakuliah ( have 5 records )

Select * from A left join B on a.nim=b.nim

The the results are minimum have 3 records plus the match record with table A

but when we change it into : Select * from A Right join B on a.nim=b.nim

then the results are minimum have 5 records plus the match record with table B.

Tips from me:
- Usually people much easier to compare between 2 table from left to right, So its better to use Left join rather than Right join.
- Before you create the query statement, make sure that the left table is the most records or it is the one that you want to keep it display the records even there is no match records in the join statement.

How is it ?There's a little bit understanding from my explain ?? Have a try, and ask if you still confuse about it.

Have a nice day.

Friday, September 26, 2008

A meaning of Failure

Today, suddenly I would like to share about what failure means from my point of view.

In this life, we experience failures. However, do we know what failure means. A failure doesn't mean hope vanishes. Sometime in failure we found new hope. For example, a few centuries ago, before science about chemistry is found, a lot of scientist try to change the structure of various object into gold. With varieties of experiment, starting from burning, spells, meditation, etc. However, some of them really try scientifically. Although experiencing failures, they begin to understand, that on earth every object is created from various kind of compound that might be organic or inorganic. From which we more familiar as element chart we studied in chemistry.

That is only one example. Of course we need to see from the positive side, which is the firmness in achieving one's purpose. Is there anything we can study from that failure. How to fix is what we call continuous improvement.

So guys, what do you think about what failure means? Does it gives you spirit to be a better person? Please look into the mirror, me myself always look into the mirror from every failure I experienced.

Have a nice day.