Solved

Using CINT in a query

Posted on 2006-10-21
2
12,939 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
  • 2
2 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 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 92

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Creating SQL script using SQL data and SQL script 8 39
SQL Server 2012 r2 - Sum totals 2 25
TSQL query to generate xml 4 34
T-SQL:  Collapsing 9 25
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

773 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