Lynda,
If your VFP cursor contains only a few records, the easiest is probably to use Claudio's suggestion of building a T-SQL command. However, if you have a lot of records, then I would use the temp table approach. In fact I use this approach in my SPT class. Example:
SELECT customer_id AS customerId;
FROM (HOME()+"Samples\Tastrade\Data\customer.dbf");
WHERE customer.country="US";
INTO CURSOR CustKeys
o.copyVfpToBackend("CustKeys", "#CustKeys", "CustomerId", .f., "CustomerId", .f., .t.)
SQLEXEC(o.inSql, "SELECT * FROM customers INNER JOIN #custKeys ON customers.customerId=#custKeys.customerId")
Here's what the method copyVfpToBackend() does in pseudo code:
- generate CREATE TABLE script based on < tcVfpTable >
- CREATE #Temp TABLE
- Read empty #temp table and convert it into an updatable SPT cursor
- append the data from the VFP cursor/table inot the updatable SPT cursor
- TABLEUPDATE()
With regards to user rights, I believe that a default user should be able to create temp tables on SQL Server.
HTH
>Is there a way to select records from a SQL Server table based upon values in a VFP cursor using SPT? In concept its simply....
>
>SELECT * from SQLTable Where PK IN (Select PK from VFPCursor)
>
>but since SQL doesn't know the contents of the VFP cursor, it's obvious why this won't work. Is some other way -- other than Scan the cursor and retrieve them one at a time...
Daniel