Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check whether field exists or stored proc exists
Message
 
À
30/08/2010 06:29:44
Hong Yew
People Quest
Malaisie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01479178
Message ID:
01479181
Vues:
48
>HI all
>
>My app is VFP9 running against MSSQL2005
>
>May I know how I can check if a field or stored proc exist in my MSSQL database.
>
>Your advice is much appreciated
>
>Thanks & Best Regards
--- Check if the field exists

IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS 
                   WHERE Column_Name = 'NameOfTheField' 
                     AND Table_Name = 'YourTable')
   SELECT CAST(1 AS bit) AS Exists
ELSE
   SELECT CAST(0 AS bit) AS Exists
--- Check if SP exists

IF EXISTS(SELECT * FROM sysobjects
                   WHERE Name = 'YourSPName' 
                     AND xType = 'P'
   SELECT CAST(1 AS bit) AS Exists
ELSE
   SELECT CAST(0 AS bit) AS Exists
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform