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)
 Getting an error

Author  Topic 

bspama
Starting Member

8 Posts

Posted - 2002-11-12 : 10:54:25
I tried this and am getting an error:

select t.eid, sl.action
from (select action from events group by action having count(*) > 1) as sl
join events t on sl.action=t.eid
order by t.eid

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



nr
SQLTeam MVY

12543 Posts

Posted - 2002-11-12 : 10:57:44
sl.action=t.eid

probably eid is integer and at least one action is 'Define Property'.

As you are outputting them both I guess they shouldn't be equal.

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

bspama
Starting Member

8 Posts

Posted - 2002-11-12 : 11:01:25
NR, yes eid is integer,

i would like to show all documents with duplicate actions and their corresponding eid's displayed.

Go to Top of Page

cat_jesus
Aged Yak Warrior

547 Posts

Posted - 2002-11-12 : 11:19:07
you must join like types. In this case you are joining the result from your derived table with your base table.


sl.action=t.eid
should be

sl.action=t.action

Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2002-11-12 : 11:19:10
quote:

I tried this and am getting an error:

select t.eid, sl.action
from (select action from events group by action having count(*) > 1) as sl
join events t on sl.action=t.eid
order by t.eid

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







I think you need

select eid, action
from
events
where action in
(select action from events group by action having count(*) > 1)
order by t.eid

Go to Top of Page

bspama
Starting Member

8 Posts

Posted - 2002-11-12 : 11:29:16
Thanks for your suggestions, it worked!

Go to Top of Page
   

- Advertisement -