473,245 Members | 1,628 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,245 software developers and data experts.

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 1769
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.