Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SET NOTATION

Author  Topic 

zippy
Yak Posting Veteran

69 Posts

Posted - 2001-10-10 : 19:25:10
Hi,

I am trying to do a SELECT using sets and 2 tables.
My two tables are as follows

ocManufacturers
ManufacturerID INT
ManufacturerName VARCHAR(20)
CategoryID VARCHAR(20)

ocSystemsCategories
CateogryID INT
CategoryName VARCHAR(20)

the CategoryID is VARCHAR in ocManufacturers because it contains a string of comma delimited id's so that each manufacturer can belong to more than one category.

I am trying to do this SELECT

SELECT dbo.ocManufacturers.ManufacturerID, dbo.ocManufacturers.ManufacturerName, dbo.ocSystemsCategories.CategoryName
FROM dbo.ocSystemsCategories CROSS JOIN
dbo.ocManufacturers
WHERE (dbo.ocSystemsCategories.CategoryID IN (dbo.ocManufacturers.CategoryID))

my problem is that it WHERE clause doesnt like comparing INT values to VARCHAR, I thought that this would be ok?
is there a way to convert it to a VARCHAR and then compare them?
The INT (ocSystemsCategories.CategoryID) value is an identity field and I dont want to have to turn it off

Second probelm is that when I convert ocSystemsCategories.CategoryID to a VARCHAR the select works but only returns recors with 1 item in ocManufacturers.CategoryID

help would be great!!

Check out the worlds fastest computers at http://www.ocgurus.com
   

- Advertisement -