DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   MS SQL (http://www.daniweb.com/forums/forum127.html)
-   -   Accesing tables rows in Stored procedure without using cursors (http://www.daniweb.com/forums/thread53745.html)

sarvesh jaiswar Aug 30th, 2006 8:59 am
Accesing tables rows in Stored procedure without using cursors
 
From last two days i am searching for the answer of this querry.
I want to know how can i access the rows of tables in stored procedures using loops(Without cursor).
We don't want to use cursor for that because of the performance issues.

itsdavetime Sep 1st, 2006 2:18 pm
Re: Accesing tables rows in Stored procedure without using cursors
 
Just to a while loop.

declare @rowcount int,
@counter int
select @rowcount = (select count(*) from table_name)

set @counter = 0
while @counter <= @rowcount
begin
select * from table_name where rowid = @counter
set @counter = @counter + 1
end

sarvesh jaiswar Sep 4th, 2006 10:32 am
Re: Accesing tables rows in Stored procedure without using cursors
 
Quote:

Originally Posted by itsdavetime (Post 248526)
Just to a while loop.

declare @rowcount int,
@counter int
select @rowcount = (select count(*) from table_name)

set @counter = 0
while @counter <= @rowcount
begin
select * from table_name where rowid = @counter
set @counter = @counter + 1
end



MY REPLY:
What was rowid here. It was giving invalid column name in SQL SERVER. PLZ reply soon.

pty Sep 4th, 2006 10:44 am
Re: Accesing tables rows in Stored procedure without using cursors
 
Quote:

Originally Posted by sarvesh jaiswar (Post 249214)
MY REPLY:
What was rowid here. It was giving invalid column name in SQL SERVER. PLZ reply soon.



your auto-incrementing id field


All times are GMT -4. The time now is 10:58 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC