Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Pass Through issue
Message
From
28/08/2008 16:36:26
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01342682
Message ID:
01342809
Views:
12
You've gotten some advice on better ways to try to create your query. However, To answer your specfic question about why you get ""Command contains unrecognized phrase/keyword."

This is the message when you try to work with a single string value longer than 255. While you can use the line continuation semi-colon to break it up, the end result is still a single string. So
? "asdfasdfasf;
1234567"
becomes
? "asdfasdf1234567"
extend that several lines and you can see how the 255 limit is exceeded.

That's one of the reasons Text/EndText is a better method. As a FoxPro dinosaur, and despite the fact that I know there are better ways, I'm more comfortable using the old fashioned
? SQLPREPARE(m.nConnectionHandle,;
     "SELECT TOP 100 PERCENT " +;
          "cast(dbo.EmployeeHours.EmployeeId as TinyInt) as EmployeeID, " +;
          "RTRIM(dbo.EmployeeList.FirstName) + ' ' + RTRIM(dbo.EmployeeList.LastName)  AS Name," + ;
          "more" +;
          "etc"
which is essentially the same as what you did, except the concatenation prevents the error.


>I'm trying to get a SQL Statement that I got working in SQL 2000 Query analyzer:
>
>Declare @cCostCode varchar(30)
>SET @cCostCode = '11708'
>SELECT     TOP 100 PERCENT cast(dbo.EmployeeHours.EmployeeId as TinyInt) as EmployeeID, RTRIM(RTRIM(dbo.EmployeeList.FirstName) + ' ' + RTRIM(dbo.EmployeeList.LastName))
>                      AS Name, SUM(ROUND({ fn HOUR(dbo.EmployeeHours.TimeOut) } + CAST({ fn MINUTE(dbo.EmployeeHours.TimeOut) } AS DECIMAL) / 60, 2)
>                      - ROUND({ fn HOUR(dbo.EmployeeHours.TimeIn) } + CAST({ fn MINUTE(dbo.EmployeeHours.TimeIn) } AS DECIMAL) / 60, 2)) AS Hours1
>FROM         dbo.EmployeeHours INNER JOIN
>                      dbo.EmployeeList ON dbo.EmployeeHours.EmployeeId = dbo.EmployeeList.EmployeeId
>WHERE     (dbo.EmployeeHours.CostCode = @cCostCode)
>GROUP BY dbo.EmployeeHours.EmployeeId, RTRIM(RTRIM(dbo.EmployeeList.FirstName) + ' ' + RTRIM(dbo.EmployeeList.LastName))
>ORDER BY dbo.EmployeeHours.EmployeeId
>
>To work in VFP9sp2, my VFP Code looks like:
>
>
>cCostCode = '11708'
>m.nConnectionHandle = SQLCONNECT('TimeClockPlus')
>? SQLPREPARE(m.nConnectionHandle,;
>	"SELECT TOP 100 PERCENT cast(dbo.EmployeeHours.EmployeeId as TinyInt) as EmployeeID, RTRIM(dbo.EmployeeList.FirstName) + ' ' + RTRIM(dbo.EmployeeList.LastName);
>                      AS Name, SUM(ROUND({ fn HOUR(dbo.EmployeeHours.TimeOut) } + CAST({ fn MINUTE(dbo.EmployeeHours.TimeOut) } AS DECIMAL) / 60, 2);
>                      - ROUND({ fn HOUR(dbo.EmployeeHours.TimeIn) } + CAST({ fn MINUTE(dbo.EmployeeHours.TimeIn) } AS DECIMAL) / 60, 2)) AS Hours1;
>FROM         dbo.EmployeeHours INNER JOIN;
>                      dbo.EmployeeList ON dbo.EmployeeHours.EmployeeId = dbo.EmployeeList.EmployeeId;
>WHERE     (dbo.EmployeeHours.CostCode = ?cCostCode);
>GROUP BY dbo.EmployeeHours.EmployeeId, RTRIM(dbo.EmployeeList.FirstName)+' '+RTRIM(dbo.EmployeeList.LastName);
>	ORDER BY dbo.EmployeeHours.EmployeeId",;
>	'QueryName')
>
>SQLEXEC(m.nConnectionHandle)
>
>BROWSE LAST NOWAIT
>
>SQLDISCONNECT(m.nConnectionHandle)
>
>
>I get the error "Command contains unrecognized phrase/keyword." and VFP highlights "ORDER BY dbo.EmployeeHours.EmployeeId",;"
>
>It's been a while since I've done anything significant in VFP and I'd like to start getting back into it, but I'm spinning my wheels here.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform