Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 2 simple Questions

Author  Topic 

Saeed
Starting Member

39 Posts

Posted - 2002-08-07 : 23:44:07
Q1
How do you get the no of records updated inserted , deleted i thnk there is a system var called @@Rec somthing that returens you with that value

Q2:
can you print something in the mid of a stored procedure and pause to see what the value is?



robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-08-07 : 23:53:28
1. @@ROWCOUNT will give you the number of rows affected by the last operation:

DELETE FROM pubs..authors
SELECT @@ROWCOUNT --returns 23

2. You can use the WAITFOR command to pause for a certain duration, but it affects the entire batch, not a specific point within the batch. You won't see the message printed until the batch completes.


Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-08-08 : 08:20:23
quote:

can you print something in the mid of a stored procedure and pause to see what the value is?



If this is really necessary, you could write the value to a table and from outside the transaction select from the table. You may need to provide some locking hints to read through the lock on your written value.

You could even program your proc to loop with a WAITFOR body, looking for a flag in a table to be set telling it that you have read the value and it may proceed.

(NOTE: both of the above suggestions have the distinct fragrance of bad database programming. Reading through locks is, IMHO, a false read. More importantly, (as Rob alluded), will hold up the transaction, thus increasing the lock time and potentially blocking other users.)

Jay White
{0}
Go to Top of Page

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-08-08 : 08:26:51
If Q2 is for debugging purposes and you are on SQL2000 you can just run the procedure through the debugger in QA and examine the values of your local variables and global variables as you step through the procedure.


HTH
Jasper Smith
Go to Top of Page
   

- Advertisement -