November 8, 2006 at 7:31 am
I cant think this morning. I want to query a table, where Rowid is plus or minus 2 of my target rowid. I cant think....can someone help?
I know its a simple stupid thing.
Much appreciated
Steve
November 8, 2006 at 7:34 am
Sorry, I didn't quite get what you want.
RowID?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 8, 2006 at 7:37 am
I have a target RowID held in a variable, I need to return the four rows that are + or - 2 of that target RowID. I know its simple....just cant think at all
November 8, 2006 at 7:41 am
Oh, that's easy.
SELECT SomeFields FROM SomeTable
WHERE RowID BETWEEN @RowID-2 and @RowID +2
It'll return up to 5 rows. If you don't want the equality condition, then add the following:
AND RowID != @RowID
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 8, 2006 at 7:42 am
Thanks....bad day here at the office!!
November 8, 2006 at 7:46 am
LOL. I know the feeling.
Good luck.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply