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)
 Incorrect syntax near the keyword 'as'.

Author  Topic 

lols
Posting Yak Master

174 Posts

Posted - 2008-02-09 : 02:45:19
What's wrong with my code

set rowcount 1
select null
while @@rowcount > 0
delete t1
from Products as t1
where t1.ProductCode =
(select top 1 t2.ProductCode from Products AS t2 group by t2.ProductCode)
as x on x.ProductCode = t1.ProductCode
set rowcount 0

I get Incorrect syntax near the keyword 'as'.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-09 : 03:05:22
quote:
Originally posted by lols

What's wrong with my code

set rowcount 1
select null
while @@rowcount > 0
delete t1
from Products as t1
where t1.ProductCode =
(select top 1 t2.ProductCode AS t2 from Products group by t2.ProductCode)
as x on x.ProductCode = t1.ProductCode
set rowcount 0

I get Incorrect syntax near the keyword 'as'.


shift AS alias before from
Go to Top of Page

lols
Posting Yak Master

174 Posts

Posted - 2008-02-09 : 03:08:57
Hi,

Thanks for replying but still the same error

set rowcount 1
select null
while @@rowcount > 0
delete t1
from Products as t1
where t1.ProductCode =
(select top 1 t2.ProductCode AS t2 from Products group by t2.ProductCode)
as x on x.ProductCode = t1.ProductCode
set rowcount 0

the error is on "as x on x.ProductCode"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-09 : 03:14:24
chage like this:-
set rowcount 1
select null
while @@rowcount > 0
delete t1
from Products as t1
inner join
(select top 1 t2.ProductCode AS t2 from Products group by t2.ProductCode)
as x
on x.ProductCode = t1.ProductCode
set rowcount 0
Go to Top of Page

lols
Posting Yak Master

174 Posts

Posted - 2008-02-09 : 03:50:23
thanks
Go to Top of Page
   

- Advertisement -