Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to return .T. of .F. from SQL server?
Message
 
To
21/03/2013 10:03:41
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01568922
Message ID:
01568923
Views:
79
This message has been marked as the solution to the initial question of the thread.
>Hi,
>
>I want to execute an IF expression against a SQL Server using SQLEXEC() and return some "meaningful" result that will tell me if IF was True or False. For example: Here is the IF expression:
>
>
>cExpr4Sql = "IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.Columns WHERE Table_Name = 'MyTable' 
>AND COLUMN_NAME = 'MyField1' AND CHARACTER_MAXIMUM_LENGTH = 50 )"
>
>
>When executing the above expression in SSMS it tells me if the column MyField1 has a length of 50 char or not.
>
>If I pass the above expression to SQLEXEC() how do I return the result? E.g.
>
>
>xReturn = SQLEXEC( nConn, cExpr4Sql )
>
>
>TIA for any suggestions.
TEXT TO cExpr4Sql NOSHOW
     IF EXISTS(SELECT *
                      FROM INFORMATION_SCHEMA.Columns WHERE Table_Name = 'MyTable'
                                                        AND COLUMN_NAME = 'MyField1'
                                                        AND CHARACTER_MAXIMUM_LENGTH = 50 )
       SELECT CAST(1 AS bit) AS FieldExists
     ELSE
       SELECT CAST(0 AS bit) AS FieldExists
ENDTEXT

xReturn = SQLEXEC( nConn, cExpr4Sql, "cCursor" )
WAIT WINDOW cCursor.FieldExists
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