Is there a System Row Count Variable? Need to get data from a row when the table has no rowcount
Posted on 2006-11-08
I need to get data from a table that doesn't have a row count number. For instance, if this was the table...
PropertyID COMMENT DATE
4 A 1-1-2005
66 B 1-2-2005
67 C 1-3-2005
This is part of a stored procedure that I'm creating. Here is the test script. XXXX is where I'm planning to put the System Row Count Number.
declare @comment varchar (4000)
declare @commentTemp varchar (4000)
declare @commentCount int
declare @commentRowCount int
set @commentCount = 0
set @commentRowCount = 0
select @commentCount = count (*) from tblPropertyComments where propertyID = 26
while @commentRowCount <= @commentCount
select @commentTemp = comment from tblPropertyComments where propertyid = 26
XXXXXX and rowid = @commentRowCount
set @comment = @comment + @commentTemp
set @commentRowCount = @commentRowCount + 1
I mean this is a fix for an issue I was having early when I would want to store data from a table. But if I had multiple returning rows, it would only store the data from the last row.