#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Sweden
    Posts
    6
    Rep Power
    0

    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.
    I need to populate the tables in my test database to run it but I dont want to write every entry in new insert statements.

    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
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,118
    Rep Power
    4274
    you could upload the data into a holding table

    here's what i do

    if the data is in comma- or tab- delimited format, or even fixed-length format (all fields start in the same column position), then i will either open it in excel, or paste into excel and use Data > Text as Columns, then save it as a spreadsheet, then DTS the spreadsheet into SQL Server

    otherwise i use search and replace in a text editor to slap the INSERT syntax around my values and run the whole series of INSERT statements in one execution in Query Analyzer

    the deciding factor, whether to go the text edit or excel/DTS route, depends on whether there are more than a couple thousand rows to do this way (search & replace is error-prone)

    rudy
    http://r937.com/
  4. #3
  5. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Spokane Washington
    Posts
    7
    Rep Power
    0
    If you just want to populate a table with dummy data, and its worth your time, you might try running the insert statement in a loop, and using the rand function to randomly generate your data. I don't think I'd go through all of this unless I needed thousands of dummy entries though

IMN logo majestic logo threadwatch logo seochat tools logo