Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to return .T. of .F. from SQL server?
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01568922
Message ID:
01568925
Views:
36
>>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
>
Thank you very much!
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform