Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

@@ROWCOUNT

Status
Not open for further replies.

carlavieira

Programmer
Aug 30, 2002
8
0
0
BR
Hi,

I have a SP and I put after close cursor this statement:

print str(@@ROWCOUNT) + 'registros incluídos.'

To know how much records are inserted.

But it didn't work. 177 records are inserted and the return was:
0registros incluídos.

Any idea about what can I do to have the number of records inserted.

Thanks

Carla
 
try
print 'registros incluídos.'
print @@ROWCOUNT

 
If you are using a cursor then you will have to define your own variable and increment it after each insertion inside the cursor loop to be able to print it later.

@@ROWCOUNT is a SQL System variable which has a value after you execute any SQL Statement which basically lets you know how many rows were affected irrespective of whether they have been deleted/updated/inserted.
 
Hi,
Try this...

Declare @intNumberOfRecords int

--cursor code


Select @intNumberOfRecords=@@ROWCOUNT

Print rtrim(convert(char(10),@intNumberOfRecords)) +
'Records Processed'

Hope it helps.

Sreenivas
avnsr@hotmail.com
-----------------
 
Hi,
Try this...

Declare @intNumberOfRecords int

--cursor code


Select @intNumberOfRecords=@@ROWCOUNT

Print rtrim(convert(char(10),@intNumberOfRecords)) +
' Records Processed.'

Hope it helps.

Sreenivas
avnsr@hotmail.com
-----------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top