Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

Transaction rowcount Expand / Collapse
Author
Message
Posted Tuesday, August 3, 2010 2:20 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, May 30, 2012 1:50 AM
Points: 143, Visits: 79
Yeah thanks...

Now i got it...

Thanks for your reply..!!!

Post #962641
Posted Tuesday, August 3, 2010 10:30 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, September 19, 2012 8:39 AM
Points: 595, Visits: 1,226
Yep. @@rowcount is a cruel mistress. I avoid her like a rash.

Converting oxygen into carbon dioxide, since 1955.

Post #962971
Posted Tuesday, August 3, 2010 3:01 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 5:20 PM
Points: 17,600, Visits: 15,462
Nice question. Thanks.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #963135
Posted Thursday, August 5, 2010 2:19 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Tuesday, October 5, 2010 6:49 AM
Points: 611, Visits: 29
Nice question, but, if we run the given script, don't we have an error on this line ?


select @@rowcount-- check this one out

EuG
Post #964050
Posted Thursday, August 5, 2010 2:58 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, May 30, 2012 1:50 AM
Points: 143, Visits: 79
No.. i'm not getting any error..

are you??
Post #964071
Posted Thursday, August 5, 2010 3:09 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, September 15, 2014 6:42 AM
Points: 365, Visits: 940
The only errors encounted would be if you didn't have the database and table already created as the script relies on them existing.

There's nothing wrong with SELECT @@ROWCOUNT -- a comment
Post #964079
Posted Thursday, August 5, 2010 3:51 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Tuesday, October 5, 2010 6:49 AM
Points: 611, Visits: 29
Ok, but i thought there was a missing blank between "rowcount" and "--"...

EuG
Post #964100
Posted Thursday, August 5, 2010 4:07 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, September 15, 2014 6:42 AM
Points: 365, Visits: 940
I may be getting confused with what you're saying..

But all of this works fine

select @@rowcount-- check this one out

select @@rowcount -- check this one out

select @@rowcount -- check this one out

select @@rowcount
-- check this one out

These would not work
select @@rowcount- - check this one out

select rowcount -- check this one out

select @@rowcount -
- check this one out

select @@rowcount -- check
this one out

We've a policy at work to use /* */ for comments where possible in case peeps run comments over a line... but it's also a pain in the backside if you want to comment out a block with these already in.

What I've found a bit weird is, if you run SELECT @@ROWCOUNT by itself in a completely fresh window then you get 1 returned... slightly odd behaviour? For example run the below script, I've used different commenting in case of line wrapping.

SELECT @@ROWCOUNT /* Will return 1, even though we've not previousiy run a statement */

SELECT 1 WHERE 2 = 1 /* Will an empty record set */

SELECT @@ROWCOUNT /* Will return 0 as expected as the previous statement returned no rows */

SELECT @@ROWCOUNT /* Will return 1 as the previous statement returned a row i.e of 0 */

Post #964103
Posted Thursday, August 5, 2010 8:29 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, May 19, 2011 7:26 AM
Points: 1,078, Visits: 289
Nice question.
Post #964329
Posted Thursday, August 5, 2010 9:29 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 9:21 AM
Points: 1,676, Visits: 1,757
Fozzie (8/5/2010)
What I've found a bit weird is, if you run SELECT @@ROWCOUNT by itself in a completely fresh window then you get 1 returned... slightly odd behaviour?

I think that there was a QotD about this in the past and it generated a lot of posts due to this behaviour. It is actually by design, and it all depends on what happens when you open first window. For example, if you open SSMS, open new window then @@rowcount is 1, but if you after opening new window go after database list dropdown and pick your database then select @@rowcount returns 0 simply because clicking in the dropdown silently issued use [your_db_name]; prior to you running select @@rowcount. Whatever settings are silently ran by SSMS depends on things such as your user options, database options, SSMS version etc. The bottom line is that when you open SSMS and do see select @@rowcount returns 1 out of the bat then it simply means that the latest silently executed for you by SSMS script affected one record.

Oleg
Post #964391
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse