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 2005 Forums
 Transact-SQL (2005)
 Delete statement not working....??

Author  Topic 

dnf999
Constraint Violating Yak Guru

253 Posts

Posted - 2007-05-21 : 06:23:47
Hi

Please can you tell me why this doesn't work!:

delete from Test_Searches a join Single_Distinct_Dupes b
on a.batesbeg = b.batesbeg
and a.ID <> b.ID
where a.Multiple_Country_Hits <> 1


Error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'a'.

Thanks!

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-21 : 06:36:00
delete theTableAliasYouWishToDeleteFromGoesHere
from Test_Searches a join Single_Distinct_Dupes b
on a.batesbeg = b.batesbeg
and a.ID <> b.ID
where a.Multiple_Country_Hits <> 1

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

dnf999
Constraint Violating Yak Guru

253 Posts

Posted - 2007-05-21 : 06:47:21
Awesome, thanks! Was really bugging me....
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-21 : 07:49:51
here's a little tip how to go about deleting data:

create a select that wil return the data you wish to delete.
then simply
replace
select ...
from ...

with
delete tableAliasFromWhichYouWantToDeleteFrom
from ....


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -