On Tue, May 31, 2011 at 11:04 AM, Rafael Copquin <[email protected]> wrote:
> I am developing a routine that randomly selects inventory items from a
> SQL Server table, for inventory control purposes.
>
> The item code is numeric, ie: 2345, 7867, 127435, etc. However, there
> are less than 2000 records in the table
>
> So I can apply the vfp rand function like so
>
> RandomNbr = int( rand(-1) * 1987 )
>
> to select a specific record, say 469, which could have an id number like
> 8976 and contain an item code like 789678
>
> If I were in VFP I would simply locate for recno() = 469 and get the
> item code.
>
> But, what is the equivalent to the recno() function in TSQL, if there is
> one? And if there is not, how do I get to the particular record?
-------------------


How many do you need to get?

A For loop with this command:
SELECT TOP 1 * FROM TheTableIneedToAudit ORDER BY NEWID()

Will give you what you need.



-- 
Stephen Russell

Unified Health Services
60 Germantown Court
Suite 220
Cordova, TN 38018

Telephone: 888.510.2667

901.246-0159 cell

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to