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)
 where exists statement

Author  Topic 

devinev
Starting Member

16 Posts

Posted - 2004-12-08 : 11:54:02
I am trying to count the number of duplicates in a table for a statistical report. I have the following transact SQL statement that is giving me an error on the equal sign in line 4:

Declare @DupeCnt int
Select StartDTG, Van into #tempcnt from Merge
WHERE Exists (Select StartDTG, Van from Merge a
where Merge.StartDTG=a.StartDTG & Merge.Van='01'
group by StartDTG, Van having count(*)>1)
Select @EmitDupeCnt=(Select count(*) from #tempcnt)
Update Merge_Stats set Dupe_Cnt=@DupeCnt
where @DupeCnt>0

Can anybody help?

Thanks,

VeeDee

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-12-08 : 12:03:47
change & to or AND...

Go with the flow & have fun! Else fight the flow
Go to Top of Page

devinev
Starting Member

16 Posts

Posted - 2004-12-08 : 12:09:07
Thanks, that was it.

VeeDee
Go to Top of Page
   

- Advertisement -