How to debuge in sql server?

It sounds difficult to find error in sql server.So ,i want to debug that statement but i dont konw how to debug.And how to debuge using sql server profilier

Usually, I put print statements before and after the statements that I want to examine in detail. Also, putting additional WHERE clauses to narrow down the result set to show only a few rows where you suspect the problem might be would help.

If you post some sample data along with your statements that you are trying to debug, people might be able to offer suggestions.