I think I broke sql

  • I received this error:

    --------------------------------------------------------------------

    Server: Msg 208, Level 16, State 1, Line 1

    Invalid object name 'upd.year'.

    Server: Msg 3624, Level 20, State 1, Line 1

     

    Location:  cache.cpp:2215

    Expression:  fFalse

    SPID:   76

    Process ID:  1212

    Description:  Missing object type mapping in IxFromObjtype

    Connection Broken

    ----------------------------------------------------------------

    Anyway, the query was:

    update gk

     set gk.signups = x.signups

      from GEO_KPI gk

      join

      (

       select

        upd.country,

        year(datecreated) as yr,

        month(datecreated) as mnth,

        count(*) as signups

        from userpersonaldetails upd

        left join Geo_KPI g

        on g.country = upd.country

        and g.yr = upd.year(datecreated)

        and g.mnth = upd.month(datecreated)

        where g.signups is null

        group by upd.country, year(datecreated), month(datecreated)

     &nbspx

      on x.country = gk.country

      and x.yr = gk.yr

      and x.mnth = gk.mnth

    ---------------------------------------------------------------

    Seems like a fairly extreme error to throw for just putting the alias in the wrong place!

    upd.year(datecreated) should have been year(upd.datecreated)

    Oh how I laughed.  :s

    And wtf is that smiley doing <_<

  • The form seems to see ) as a smirk smiley when on the line first in code fo whatever reason like so

    )

    if you post code and then go in and put a space in front (you can even remove the space) it seems to deal better.

     

    As for the other it is a generic error an I see these often an that is just what they choose.

  • Your SQL has this in the WHERE clause

    and g.yr = upd.year(datecreated)

    and g.mnth = upd.month(datecreated)

    Remove the "upd." before the year and month system functions, to look like:

    and g.yr = year(datecreated)

    and g.mnth = month(datecreated)

    SQL = Scarcely Qualifies as a Language

  • Thanks - I think I mentioned that.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply