• SQL provides us with a very powerfull tool to do this too: the union all statement. You can use this to generate, for example, a single statement that inserts multiple rows like this:

    insert into dbo.table( col1, col2, col)

    select 'some', 'value', 10

    union all select 'another', 'value', 11

    and an update statement can be constructed like this:

    update tbl

    set

    col1 = t.col1,

    col2 = t.col2

    from dbo.table tbl

    inner join (

    select 'some' as col1, 'value' as col2, 10 as col3

    union all select 'another', 'value', 11

    ) t on (t.col3 = tbl.col3)

    One big advantage can be that this fires any triggers on the table only once for the entire set and not over and over for each row. Having this sort of tricks available can realy save your day.

    edit: sorry to duplicate sql's idea, I hadn't opened the 2nd page of results yet.



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?