?
Solved

Using CINT in a query

Posted on 2006-10-21
2
Medium Priority
?
14,034 Views
Last Modified: 2008-03-03
Hi experts

My SQL query :

SQL = SQL & " AND ((cint(ShipOther1) <= " & ProdWeight & " AND " & ProdWeight & " <= cint(ShipOther2)) " 
               SQL = SQL & " OR (ShipCost1 <= " & ProdWeight & " AND " & ProdWeight & " <= ShipCost2)) " 

Returns an error:

Microsoft OLE DB Provider for ODBC Drivers erreur '80040e14'

(Microsoft}(ODBC SQL Server Driver}(SQL Server}'cint' is not a recognized function name.

/shopshippingcalc.asp, ligne 538

How can i fix this ?
Thx
0
Comment
Question by:humer2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 17779948
CInt() is not a SQL Server function--it is an Access/VB/VBA function.

For SQL Server, use CAST or CONVERT:

CONVERT(data_type, expression, [optional format type])
CAST(expression AS data_type)

SQL = SQL & " AND ((CONVERT(int, ShipOther1) <= " & ProdWeight & _
    " AND " & ProdWeight & " <= CONVERT(int, ShipOther2)) OR (ShipCost1 <= " _
    & ProdWeight & " AND & ProdWeight & " <= ShipCost2)) " 

You may also need to replace the & within the quotes to be + (SQL Server uses + as a string
concatenator).

Patrick
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 17779964
Also be advised that the Integer data type for Access/VB/VBA is *not* the same as the
int data type in SQL Server.  SQL Server's int data type is analogous to the Access/VB/VBA
Long, and SQL Server's smallint data type is analogous to the Access/VB/VBA Integer.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question