Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL to find if key exists
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01476366
Message ID:
01476370
Vues:
73
>I need a SQL to find if a key exists in a table. I'm trying to do everything in SQL now. Before I would simply open the table, set the index and do a SEEK(). I there are 1.5 million recs in this table and the key could exists thousands of times or not at all.

In SQL Server:
select cast(case when
 exists (select 1 from SomeTable where SomeField = @Val) then 1 end 0 end as bit) as ValueExists
If you need to do this in VFP, then
select top 1 PKField from myTable where exists (select 1 from myTable where myField = MyValue) order by PKField
Indexseek() on VFP table will probably be faster.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform