Hi Suresh
Your sample stored procedure is Fine.
But, You have to consider something as follows...
1. Apropos the recommendation, NOCOUNT should be ON, Anyway you have also used the "SELECT @ReturnValue" so you will have resultset (or) Try to put some comment like Why you have used "NOCOUNT OFF" here... Otherwise, the Users/audience will get confuse.....
2. @@ROWCOUNT statement should be used immediate of the statement you want to capture the affected state. But you have used "SCOPE_IDENTITY()" prior to "@@ROWCOUNT", So the Affected rowcount always "1"..... , So, Kindly change the sequence of the statements as given below...,
INSERT Statement......
SET @ReturnValue = @@ROWCOUNT
SET @Address_id = SCOPE_IDENTITY()
But, as per your code, the INSERT statement also inserts one row, You have to consider all the scenarios, Then only your sample is usefull to the users(Beginners)
Note: When you try to steer something to audiance/user, QUALITY is very important...
Cheers
www.sqlserverbuddy.blogspot.com Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions
Gokul, if this helps please login to Mark As Answer. | Alert Moderator