Insert statement question (multifield) #2

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ted Greek

    Insert statement question (multifield) #2

    How do I get two values for two different fields in an insert statement
    values clause using one select?

    For instance:

    declare @test int
    @test gets assigned...

    insert into (id, field1, fname, lname)
    values
    (@id,
    case @test
    when 1 then 'a'
    when 2 then 'b'
    end,
    select names.fname, names.lname from names where names.id = @id,
    <??????????>
    )

    What I want to do is get both the first and last names for both insert
    assignments using one select rather that either one select assigning to
    variables or two selects in insert values clause.

    Thanks.




Working...