CAST function question

  • Thread starter Thread starter Anne
  • Start date Start date
A

Anne

Hello! I have the following SQL code:

SELECT AgtFirstName + ' ' + AgtLastName + ' has a projected income of ' +
CAST(Salary + (50000 * CommissionRate) AS CHARACTER)
AS ProjectedIncome
FROM Agents;

When I run it, I get the following message: Syntax Error(Missing Operator)
in query expression...
What am I doing wrong? Any help would be appreciated.
Thanks
 
If you are using Jet, instead of MS SQL Server, try:



SELECT AgtFirstName & ' ' & AgtLastName & ' has a projected income of ' &
(Salary + (50000 * CommissionRate))
AS ProjectedIncome
FROM Agents;



Vanderghast, Access MVP
 
If you need explicit cast, it is probably like CDbl(), CDec(), CDate( ),
.... but Jet has much more 'automatic' casting than MS SQL Server does, so,
you are unlikely to need some explicit cast, at least, not when strings
concatenation is involved. You could need casting if you want to convert
from a string to a date, like:

CDate("Jan 1, 2009")


Vanderghast, Access MVP
 
Back
Top