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
 SQL Server Development (2000)
 data type problem

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-03-07 : 07:40:25
aks writes "Hi,
I have a table with 3 columns as int,datetime & text.
Int date text OUTPUT
4 4
0 2004-09-06 2004-09-06
0 test test
6 6

I'm trying to get the OUTPUT column.
select cast(a.date as varchar),cast(a.text as varchar),
cast(b.text as varchar), cast(a.int as varchar),
cast(b.int as varchar),
case
when a.textfield is null then a.date
else b.date
end,
CASE
when a.textfield is null and a.date is null then a.int
else b.int
end
from secunsec a FULL OUTER JOIN secunsec b
ON a.uid=b.uid
where (a.textfield<>0 or b.textfield <>0)
AND (a.date <>0 or b.date <>0)

But I'm getting error"Syntex error in converting text"test " to a data type int..
What should I do????"

nr
SQLTeam MVY

12543 Posts

Posted - 2005-03-07 : 08:49:02
Havn't we done this before.
0 is an int so a.textfield<>0 will try to convert textfield to int and fail.
It needs to be a.textfield<>'0'

==========================================
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 -