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.
| Author |
Topic |
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2011-05-27 : 07:07:38
|
| Hi All,How to take the count of record from cusrsor ?Thanks and Regard'sHarish Patil |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-05-27 : 07:24:54
|
| Not sure what you mean. Select count(*) from yourTable?JimEveryday I learn something that somebody else already knew |
 |
|
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2011-05-27 : 07:58:38
|
| are you counting based on a particular criteria? |
 |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-05-29 : 18:59:29
|
| Why are you writing a cursor at all? Why not use a COUNT(*)? That will give you the number of rows in a table which is not quite the same as a count of records in a cursor.--CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2011-05-30 : 02:56:42
|
| You should generally stay away from cursors, they are the devil.Now regardng your question: SELECT @@CURSOR_ROWS From BOL: @@CURSOR_ROWS Reports the number of rows populated in the last cursor opened for the connection. - LumbagoMy blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/ |
 |
|
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2011-05-30 : 04:32:47
|
| Hello Friend,I have tried "@@CURSOR_ROWS" but it returns -1 if rows available in cusrsor. I am having following cursor, in that i want all field from select staement and i want count of record also coz i want to check if records are more than 1.Can you please help me how to do this ?DECLARE find_lcc_cursor CURSOR LOCAL FORWARD_ONLY READ_ONLY FORSELECT INRS.ID AS Normalized_Rate_Sheet_ID, WS.ID as Work_Sheet_ID,Call_Completion, INRS.Rate FROM tb_lcr_international_normalized_rate_sheet INRSINNER JOIN tb_lcr_work_sheet WS ON INRS.Work_Sheet_ID=WS.IDINNER JOIN tb_lcr_rate_sheet RS ON RS.ID=WS.Rate_Sheet_ID INNER JOIN tb_lcr_carrier C ON C.ID=RS.Carrier_IDINNER JOIN tb_lcr_country Coun on COUN.ID=INRS.Country_IDWHERE COUN.Code=@Country_Code AND Dialed_Digits=@Dialed_Digits AND INRS.Status=1 AND RS.ID IN (SELECT Rate_Sheet_ID FROM tb_lcr_rate_deck_detail RD INNER JOIN tb_lcr_rate_deck_carrier_rate_sheet RDRSH on RDRSH.Rate_Deck_Details_ID=RD.ID WHERE RD.ID=@Rate_Deck_Detail_ID)ORDER BY INRS.Rate,C.priority,INRS.Work_Sheet_IDThnks,Harish |
 |
|
|
|
|
|