Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check whether field exists or stored proc exists
Message
 
To
30/08/2010 06:29:44
Hong Yew
People Quest
Malaysia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01479178
Message ID:
01479181
Views:
47
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform