-----Ursprüngliche Nachricht----- Von: Rafael Copquin [mailto:rafael.copquin@gmail.com] Gesendet: Donnerstag, 26. Oktober 2017 17:09 An: Jürgen Wondzinski juergen@wondzinski.de Betreff: Re: AW: recno() function in tsql
Hi Woody
It's been a long time! Welcome back!
FYI, I always build all my tables with autoincrementing primary keys. In this particular case the table I am dealing with has 10000 records. The primary keys go from 1 to 10000.
But i want to select a small set based on a date range (it is a sales table)
I just want the first column of the selected cursor to contain the record number and the other columns the rest of the data.
So I should be getting something like this:
RecordNo ID Date etc
1 5421 2017-06-15
2 5422 2017-06-15
3 5423 2017-06-16
etc
Rafael
El 26/10/2017 a las 12:00, Jürgen Wondzinski escribió:
In SQL each record has to have a PrimaryKey (Field) for identifying it, since SQL doesn't know of records, it knows about result-sets instead.
The RECNO() in xBase is just the same concept: a unique identifier for the current session, not meant for a longterm relation setting. If you designed your SQL table without a unique identifier, then you're out of luck :)
wOOdy
-----Ursprüngliche Nachricht----- Von: ProFox [mailto:profox-bounces@leafe.com] Im Auftrag von Rafael Copquin Gesendet: Donnerstag, 26. Oktober 2017 16:34 An: profox Betreff: recno() function in tsql
Is there an equivalent to the VFP recno() function in T-SQL?
I'd like to create the following select statement in T-SQL:
select recno(),otherfields..... from database.dbo.table
If there is not, what would be a substitute?
Rafael Copquin
[excessive quoting removed by server]
fwiw this works - (use dbc, remote view, cursor adaptor, w.h.y for line 1 :-
SELECT * FROM somewhere WHERE type = "myType" INTO CURSOR tmp SELECT RECNO() as id, * FROM tmp
That works for dbf tables, but not for SQL Server tables
Thanks
Rafael Copquin
El 27/10/2017 a las 14:40, AndyHC escribió:
fwiw this works - (use dbc, remote view, cursor adaptor, w.h.y for line 1 :-
SELECT * FROM somewhere WHERE type = "myType" INTO CURSOR tmp SELECT RECNO() as id, * FROM tmp
[excessive quoting removed by server]