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)
 Weird SQL Query

Author  Topic 

scelamko
Constraint Violating Yak Guru

309 Posts

Posted - 2008-03-26 : 15:29:11
Guys,

I have a weired issue here

insert into

select [value] from cfg_elements WHERE ELEMENT_NAME='REPORT_ARBITRATOR_EVENTTYPCDS'
--- result '45','95'

when I run the following subquery I get results

select * from employee where employee_typ in ('45', '95')
--- I get 4 rows

but when I run the below statement I do not get any results

select * from employee where employee_typ in (select [value] from cfg_elements WHERE ELEMENT_NAME='REPORT_ARBITRATOR_EVENTTYPCDS')

Any suggestions and inputs would help

Thanks

nr
SQLTeam MVY

12543 Posts

Posted - 2008-03-26 : 15:35:35
try
select t.*
from employee t
join (select distinct [value] from cfg_elements WHERE ELEMENT_NAME='REPORT_ARBITRATOR_EVENTTYPCDS') t2
on t.employee_typ = t2.[value]

and

select * from employee where employee_typ in (select [value] from cfg_elements WHERE ELEMENT_NAME='REPORT_ARBITRATOR_EVENTTYPCDS' where value is not null)

If that doesn't help check the datatypes.




==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -