RE: vfp vs tsql

Author: Lou Syracuse

Posted: 2011-05-31 at 12:23:59

As you have found SQL Server has no concept of record numbers...

What you could do is add an integer column to that SQL Table (assuming you

have rights to do so), and under the settings for that column expand

"Identity Specification" and set (is Identity) to yes. This will set the

column up much the way VFP does with its Auto-incrementing integer.

Then reference that field with your randomly-generated number using the

max() of the new field which You'll have to make a call to SQL to obtain

first. Be sure to make sure you have a record returned when you make the

call, if records are deleted from that table the ID's are not recycled so

you could end up doing a query against a record that has been deleted and

therefore not get a record back.

Lou

-----Original Message-----

From: profoxtech-bounces@leafe.com [mailto:profoxtech-bounces@leafe.com] On

Behalf Of Rafael Copquin

Sent: Tuesday, May 31, 2011 9:04 AM

To: profoxtech@leafe.com

Subject: vfp vs tsql

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?

Rafael Copquin

[excessive quoting removed by server]

_______________________________________________

Post Messages to: ProFox@leafe.com

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/0cf701cc1faf$2656eab0$7304c010$@com

** 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.

©2011 Lou Syracuse