Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select VFP vs SQL Server
Message
From
05/06/2015 13:50:32
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
16/09/2014 09:08:56
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01607580
Message ID:
01620677
Views:
127
>>>>Hi,
>>>>
>>>>I ran into the following, fairly small, issue. I use Stonefield Query (older version) which returns the following expression (when you select one of several):
>>>>
>>>>
>>>>SELECT * FROM MyTable WHERE (inlist(upper(MyTable.MyField),'TEST1','TEST2',))
>>>>
>>>>
>>>>Note that trailing comma, after ('TEST2'). When I execute this expression against VFP database I get error. When I execute this SQL Select against SQL Server, no error.
>>>>
>>>>Does it mean that SQL Server ignores the trailing comma? Or there is another reason for difference for this behavior between VFP and SQL?
>>>
>>>Hi, Dmitry,
>>>
>>>First, the SQL database engine doesn't have INLIST. Just IN.
>>>
>>>This works:
>>>select * from Production.product where productid in (1,2,3)
>>>
>>>This doesn't:
>>>select * from Production.product where productid in (1,2,3,)
>>
>>Kevin,
>>
>>You are correct. SF Query uses IN where for VFP it uses INLIST. And when it uses IN (for SQL Server) it does not leave trailing comma. So it must be a small bug in their software. Since I have the source code I will have to "dig into" and find where to make sure that the trailing comma for VFP has to be "deleted" or not "added"
>>Thank you.
>
>That is another reason I always concatenate the comma without any conditional checks and then delete the one trailing comma afterward. Firing a conditional check for each loop is not efficient in the long run.
>
>for x = 1 to 10
> lcString = m.lnString + "a" + ","
>endfor
>lcString = left(m.lcString,len(m.lcString)-1)

Whats wrong with
lcString = ''
for x = 1 to 10
  lcString = m.lcString+ "," + "a" 
endfor
lcString = SUBSTR(m.lcString,2)
?
Just a clear simple command.
Works even with the empty string ...
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Reply
Map
View

Click here to load this message in the networking platform