473,463 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Possible Bug in SQL Server 2000?

Hi guys,

I have hit this bug more than once and was wondering if anyone else
has ever seen it?

SELECT A.nId
,B.nId
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
WHERE A.nId IN (SELECT cId
FROM Server1.myDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
or
B.nId IS NULL
LogTable.cId is a varchar(15) but it only has numeric data where
cTableName = 'TableA'.

I get the following error when I execute the statement.

Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value '1-L7Z5X' to a column of
data type int.

'1-L7Z5X' does exist in LogTable but not for 'TableA'.

Any thoughts?
Jul 20 '05 #1
3 1773
Is LogTable.cId varchar? You might want to restrict the where clause not
only to TableA but also to those rows where the value is actually numeric.

Or, convert A.nId to a VARCHAR before comparing.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Dave" <da*********@softhome.net> wrote in message
news:14**************************@posting.google.c om...
Hi guys,

I have hit this bug more than once and was wondering if anyone else
has ever seen it?

SELECT A.nId
,B.nId
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
WHERE A.nId IN (SELECT cId
FROM Server1.myDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
or
B.nId IS NULL
LogTable.cId is a varchar(15) but it only has numeric data where
cTableName = 'TableA'.

I get the following error when I execute the statement.

Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value '1-L7Z5X' to a column of
data type int.

'1-L7Z5X' does exist in LogTable but not for 'TableA'.

Any thoughts?

Jul 20 '05 #2

"Dave" <da*********@softhome.net> wrote in message
news:14**************************@posting.google.c om...
Hi guys,

I have hit this bug more than once and was wondering if anyone else
has ever seen it?

SELECT A.nId
,B.nId
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
WHERE A.nId IN (SELECT cId
FROM Server1.myDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
or
B.nId IS NULL


Sql Server is free to reorganize this query, transform the subquery into a
join, and evaluate the join criterion before the where-clause criterion. Try
casting nID to a varchar before the comparison.

SELECT A.nId
,B.nId
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
WHERE cast( A.nId as varchar(15)) IN (SELECT cId
FROM Server1.myDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
or B.nId IS NULL

David
Jul 20 '05 #3
On 8 Jul 2004 09:52:24 -0700, Dave wrote:
Hi guys,

I have hit this bug more than once and was wondering if anyone else
has ever seen it?

SELECT A.nId
,B.nId
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
WHERE A.nId IN (SELECT cId
FROM Server1.myDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
or
B.nId IS NULL
LogTable.cId is a varchar(15) but it only has numeric data where
cTableName = 'TableA'.

I get the following error when I execute the statement.

Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value '1-L7Z5X' to a column of
data type int.

'1-L7Z5X' does exist in LogTable but not for 'TableA'.

Any thoughts?


It's not a bug. You're asking SQL to compare A.nID to each value in the
subquery. It tries to do that by (an implied) convert(int,...) operation,
which fails for the value in LogTable.

Either convert a.nID to varchar, or restrict the values in the subquery to
those that are actually numeric.

SELECT A.nID, B.nID
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB ON B.nID = A.nID
WHERE convert(varchar(15),A.nID) IN
(SELECT cID FROM Server1.MyDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
OR b.nID IS NULL

...... or .........

SELECT A.nID, B.nID
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB ON B.nID = A.nID
WHERE A.nID IN
(SELECT cID FROM Server1.MyDB_3.dbo.LogTable
WHERE cTableName = 'TableA' and ISNUMERIC(cID))
OR b.nID IS NULL
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gervin | last post by:
That was the first question. BTW, I am using Windows 2000 Server. Second questions is how do I transfer session variables from one virtual website to another website. Currently I have session...
3
by: Scott | last post by:
I have been told that the only way to develop an ASP.NET application is to do it on the localhost, and then just copy the files out to the web server that will be hosting. Is this true? ...
2
by: Jay Chan | last post by:
We have just installed a SQL Server 2000 (SP 3A) onto a computer that has Windows-2003 Server on it. Now, we cannot get access to that database server from other computers. Seem like this may be an...
22
by: Robert Brown | last post by:
suppose I have the following table: CREATE TABLE (int level, color varchar, length int, width int, height int) It has the following rows 1, "RED", 8, 10, 12 2, NULL, NULL, NULL, 20...
4
by: Bon | last post by:
Hello all Would it be possible to migrate the MS Access 2000 to MS SQL Server 2000? My application is using MS Access 2000 as database and as user interface such as forms. Now, I want to...
2
by: D.Rider | last post by:
Access 2000 database on Windows 2000 server. Is it possible to see who has db open from within Access? Or from Windows 2000 Pro by non-administrator? I can see who has open via Server, but...
1
by: Rico | last post by:
Hello, I have a database in 2005 that I'd like to copy and attach in 2000. Is this possible? if so, how do I do it? I've tried doing a number of things from just trying to attach to the db...
14
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
1
by: klaydze | last post by:
hi guys, is it possible that i can retrieve records from different database like SQL Server 2000 and MySQL? example, assuming i have some table in SQL Server 2000 and i also have in MySQL. the table...
1
by: Jeremy Pavleck | last post by:
Just curious if it's possible, and supported, to upgrade SQL 2005 from 32bit to 64bit. This is on top of Windows 2003 64bit. Trying to get the proper supported config for OM2k7 without blowing...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.