SQL Server

What is it? Many people wonder why SQL server? why not other Databases. To answer this question, its a long story how databases came into IT world.

I am taking a detail training on various concepts of SQL server. Soon, I will be updating all of my learning here. Wait and watch!

Performance

This is a big problem in the industry, no matter how well DB objects are designed still we do not have end to this problem. So, how we are going to solve this problem? Answer depends on various factors of the DB design and it's usage.


OUTPUT variable

Today I had a crazy situation where using OUTPUT variable landed me in an project emergency where I had to break my head to fix this issue.

Situation is some thing like this:

With in SP1  - there is a call to SP2 with OUTPUT variable

Now, SP2 is looped in WHILE loop to call multiple times based on some conditions of SP1

Based on the iteration in WHILE loop and result of SP2, final result of SP1 is sent back to the caller.

When I looked at the code, everything seems to be fine. But there is an issue raised by the users saying they are having the data (ex: field one returned by SP2) for all the conditions.

I broke my head and did a detail analysis then I found the problem.

In the WHILE loop, first time when SP2 is called, then it brings some value in the OUTPUT variable which is being not set in subsequent calls.

Meaning, every time when u call any SP make sure, you set the OUTPUT variable to NULL.

I hope, this helps to the developer.

Please post me if you have any questions.

No comments:

Post a Comment