look at this too:
Main Topics
Browse All TopicsHello dear experts,
I have switched from native DBFs to SQL-Server and Cursor Adapter and have a problem. I have created a few indexes for a table on SQL-Server 2005 . Would you please help me , how can i set the order of this table to these tags (keys).
Example
Table Name: Mytable
Index keys generated on SQL-Server (not the CDX tags): ord_1, ord_2, ord_3
I know that in native DBF version we open the table and say "set order to xxxxxxx"
I create the cursor adapter, open the table, select the alias, but i can not say set order to ord_1.
I want to have the similar function as set order to ord_1, in other words i want to order the selected table on the generated keys (ord_1, ord_2, ord_3) .
Notice: I know that we can say " ccc =SQLEXEC(conn_value, "select * from Mytable order by fieldxxx") " but i want to use the generated keys for the table on sql-server.
Many many many Thanks in advance...........
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
It is just SQLEXEC(conn_value, "select * from Mytable order by fieldxxx") which uses index generated on SQL (if it exists). And it is the intention of SQL indexes to use them remotely this way. If you need different index order of one table at the same time then you have to create several cursor adapters each one having different ORDER BY clause...
All other ways can use indexes created in VFP only.
Cursor adapter behaves as native VFP cursor which cannot use SQL indexes directly. But you can create indexes yourself after cursor is created or filled, e.g. in AfterCursoFill event.
You have to explicitly write standard VFP INDEX command:
INDEX ON YourColumn TAG YourTagName1
INDEX ON YourColumn2 TAG YourTagName2
and use it as standard VFP index, i.e. SET ORDER TO YourTagName1
More sophisticated way could read index definitions from SQL Server and create appropriate tags on VFP cursors but you'll still need their names hardcoded in VFP app code.
you actually mentioned the word INDEX but I was thinking you are doing that for getting key value of index which is not possible in SQL Server, however you can have Row_Number to get key of each row based on the column(s) you decide.
If you want to create index to get good performance on SELECT statement or physically arrange the rows than kindly follow below given links.
http://www.exforsys.com/tu
http://searchsqlserver.tec
Welcome in VFP world RiteshShah!
I would recommend some publications from Hentzenwerke: http://www.hentzenwerke.co
Seriously, I am sure you'll find many useful features which are still missing (or too complex to implement) on SQL Server. To have both Front and Back-end in one box is not as bad.
Hello dear experts/RiteshShah:,
Many many thanks for the comments and the solutions.My problem is as follws:
I have created for tabke_one a few indexes on SQL Server 2005 and use this table as a cursor adapter in programm. But i dont know how to use these indexes from in programm written in Visual FoxPro 9 !!!!
For example i have ca_one and it uses the table table_one, i have created 4 indexes on SQL Server 2005 and want to set the ordes . For example i want to say:
select table_one
set order to index_1 or index_2 ...etc.
many many thanks in advance....
Did you read the answer ID:25299143 ?
You may use indexes created on SQL Server same way as you are using them on SQL Server only. Means in ORDER BY clauses and JOINs.
SET ORDER TO is FoxPro command and it is not applicable to SQL indexes. To use this command you have to create your own (new) indexes in FoxPro environment:
SELECT table_one
INDEX ON <IndexExpression1> TAG index_1
INDEX ON <IndexExpression2> TAG index_2 ADDITIVE
INDEX ON <IndexExpression3> TAG index_3 ADDITIVE
INDEX ON <IndexExpression4> TAG index_4 ADDITIVE
SET ORDER TO TAG index_1
Hello dear pcelba:
many many thanks for your guide and help. I mean, how can i use the keys ( i mean the generated indexes ) on the SQL server for a certain table ?
A table named "youth" on the SQL Server has a few index keys. Is it possible ( without generating new indexes --using INDEX ON <IndexExpression1> TAG index_1---) to use the existing keys on SQL server from FoxPro programm?
many many many thanks in advance
I understand what you are asking for.
The only operation you can do on SQL indexes beside the ORDR BY, GROUP BY, JOIN is:
1) You can read the index definition from SQL Server.
2) You can DROP INDEX on SQL Server
3) You can CREATE INDEX on SQL Serve
You cannot use existing keys in FoxPro, you cannot optimize your FoxPro cursors by attaching them into SQL Server indexes.
BTW, why you don't like the idea to create FoxPro indexes on CA cursors? Index creation is fast and it could speed up data operations if your cursors are very large.
Your last question is ansvered here: http://www.experts-exchang
Business Accounts
Answer for Membership
by: RiteshShahPosted on 2009-09-10 at 04:27:20ID: 25299105
I am not sure but do you need query something like this?
Select allOpen in new window