Funny Update Statement?

  • I've been re-formatting ola hallengren's sql maintenance script so I can read and understand it before trying it out on a development server.

    It has a command I don't understand.

    Is it silly SQL or am I just missing something important?

    UPDATE @tmpIndexes

    SET Selected = 1

    FROM @tmpIndexes

    What's the purpose of the from clause here? I don't see what use it servers.

  • its not needed there, but it is valid syntax.

    The probability of survival is inversely proportional to the angle of arrival.

  • david_wendelken (9/21/2010)


    I've been re-formatting ola hallengren's sql maintenance script so I can read and understand it before trying it out on a development server.

    It has a command I don't understand.

    Is it silly SQL or am I just missing something important?

    UPDATE @tmpIndexes

    SET Selected = 1

    FROM @tmpIndexes

    What's the purpose of the from clause here? I don't see what use it servers.

    The purpose of from clause look this

    declare @data table (i int, j int)

    declare @data1 table (i int, j int)

    insert into @data

    select 1,1

    union select 2,5

    unionselect 3,8

    unionselect 4,10

    insert into @data1

    select 1,11

    union select 2,51

    unionselect 3,81

    unionselect 4,101

    Update a set a.j=a.j+1 from @data1 as a join @data as b on a.i=b.i

    select * from @data1

    If you are combining more than one table from clause is used same way you have done for single table it all depends on how we treat a query.

    Thanks

    Parthi

    Thanks
    Parthi

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

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