Sql Inserting Multiple rows into a Table

After spending hours trying to work out why the sql bulk insert command refused to work. (it always claimed it could not open the file but the permission sets looked fine) I found Pinalkumar Dave’s blog at http://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/ and the example code worked wonderfully for me. So I had to do was to edit the data file, but a few change and replaces are better the inserting the values n times

A quick example

Insert into usage (Forename,Surname,Town)
Select ‘Fred’,’Smith’,’Manchester’
union all
Select ‘Bob’,’Jones’,’Wigan’
union all
Select ‘Anna,’Bell’,Stockport’’

So thank you again Pinal Dave

This entry was posted in Tech Watch and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>