Carl Henthorn
3/21/2007 10:24:00 PM
try this:
select a.memberid,a.adminactionmask,a.insertdate
into #tmp2
from clsql5.db1.dbo.adminactionlog a
left join clsql5.db1.dbo.adminactionlog b
on a.memberid = b.memberid
and a.insertdate = max(b.insertdate)
where a.adminactionmask & 4 = 4
and a.insertdate between '03/07/2007' and '03/21/2007'
"Pat" wrote:
> Hi Freinds,
> Trying to run this
>
>
> select a.memberid,a.adminactionmask,a.insertdate
> into #tmp2
> from clsql5.db1.dbo.adminactionlog a where a.insertdate = (select
> max(b.insertdate) from clsql5.db1.dbo.adminactionlog b where
> a.memberid = b.memberid )
> and a.adminactionmask & 4 = 4 and a.insertdate > '03/07/2007' and
> a.insertdate < '03/21/2007'
>
>
> and getting this strgane erro :
>
> Server: Msg 8180, Level 16, State 1, Line 1
> Statement(s) could not be prepared.
> Server: Msg 107, Level 16, State 1, Line 1
> The column prefix 'a' does not match with a table name or alias name
> used in the query.
>
> any idea ?
>
> the statment without the into #tmp2 is running perfect, I even tried
> to use insert into #tmp2 and got same error !
>
> Thanks in advance,
> Pat
>
>