Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Location
    Sweden
    Posts
    19

    Unanswered: insert multiple values

    How do I write the different values together in the first statement instead of writing it twice like this???
    Im writing in T-SQL.

    USE Test
    INSERT INTO table1 (A, B, C, D,
    E, F, G,H)
    VALUES ('lala', 'Bob', 'Swanson', 'Brook Ave 541', '274 37', 'USA'
    , '002-326565656', 'ps@aol.com')

    USE Test
    INSERT INTO table1 (A, B, C, D,
    E, F, G,H)
    VALUES ('blabla', 'Anna', 'Asey', 'Brook str 19', '274 37', 'Skivarp'
    , '04-12565656', 'aa@aol.com')

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Re: insert multiple values

    Is it what are you looking for?

    USE Test
    INSERT INTO table1 (A, B, C, D,
    E, F, G,H)
    select 'lala', 'Bob', 'Swanson', 'Brook Ave 541', '274 37', 'USA'
    , '002-326565656', 'ps@aol.com'
    union all
    select 'blabla', 'Anna', 'Asey', 'Brook str 19', '274 37', 'Skivarp'
    , '04-12565656', 'aa@aol.com'

  3. #3
    Join Date
    Sep 2003
    Location
    Sweden
    Posts
    19

    Re: insert multiple values

    What I want to be able to do is to add data for multiple post in the same INSERT INTO ...VALUES().
    I have seen it done somewhere but dont remember, but the way you have suggested is not it.



    Originally posted by snail
    Is it what are you looking for?

    USE Test
    INSERT INTO table1 (A, B, C, D,
    E, F, G,H)
    select 'lala', 'Bob', 'Swanson', 'Brook Ave 541', '274 37', 'USA'
    , '002-326565656', 'ps@aol.com'
    union all
    select 'blabla', 'Anna', 'Asey', 'Brook str 19', '274 37', 'Skivarp'
    , '04-12565656', 'aa@aol.com'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •