insert statement

Results 1 to 3 of 3

Thread: insert statement

  1. #1
    Madhu Guest

    Default insert statement

    How to insert 25 rows at a time in the table?database using is sqlserver.

  2. #2
    SPG Guest

    Default RE: insert statement

    (afaik) In Base SQL Theory, there is no sound way to perform 25 valued inserts as a single atomic unit, due to fundamental constraints which you should have placed on your table -- each record should be inserted individually so it can be error checked and, if necessary, thrown out without disturbing the rest of your inserts.<BR><BR>If you actually want them to all fail together, drop them in a transaction that rolls back on a single failure.<BR><BR>If faced with a block of inserts, here&#039s what I might try:<BR><BR>Option 1) you should be able to do an "insert into tbl (foo, bar) [ selectQuery ]" if that would work for you -- though if you&#039ve got user input, this prolly won&#039t help... (I suspect that the SQL theory behind this is that if any of your inserts fail then you were breaking some relational restriction anyway, hence they should all fail)<BR><BR>Option 2) you could write a stored procedure that would take a slathering of variables and toss them into inserts. (Sorry, I don&#039t write these -- they don&#039t pay me enough to be a DBA.)<BR><BR>Option 3) you could write a loop to do the "insert into tbl (foo, bar) values (&#039" & strFoo & "&#039, &#039" & dateBar & "&#039)" for a whole batch of foos and bars.<BR><BR>I would start with option 3 (it&#039s easist) and go from there.

  3. #3
    madhu Guest

    Default Thankyou

    Option 3 is easy but the problem is mail DBA don&#039t want to take data from my copy of the database.he just want the script and he wants to run it on his copy(with some name modifications) and he don&#039t want to enter the data record by record.he just want to press run so everything will be done.<BR>Any way thank you very much for ur help.<BR>Keep track I will bug you with more questions.<BR>

Posting Permissions

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