Hi Abdul,
That is because, after successful execution of any statement the SQL server variable @@ERROR would have the success or error status of the last statement executed. Anything other than ZERO indicates the error. In your case, it has been successfully executed, so you get a ZERO as @Rslt.
I wonder why you have to complicate things by having to execute a sql string, as it seems you are running it to get max(col), is that going to return the same max(col) except that the other factors might change? If not you don't have to go for executing dynamic sql string when the result is NOT going to be different each time.
But I dont think you can get there by the way you have mentioned.
Execute @Rslt = sp_excutesql @StrSQL
Instead you can use it as suggested by om_prakash in his post earlier, which I feel would be round the circle to achieve.
You can take a look at this page to understand how OUTPUT parameter works and fit that into your solution.
http://www.sqldts.com/?234
Hope that helps.
Cheers!
_________________________
-Vijay G

Strive for Perfection
