August 4, 2004 at 5:44 am
Hello!
I have one little problem with a bulk insert. This is the first time I've used it - so.....
I'm having one database with a lot of fields - and one text file with only three columns. They are suppose to be inserted at place four, six and eight in this table. How can I do that? I can't find it in the bol - but if I can use bcp utility - how do I do that? Should I use a temporary table and insert it from there?
-Lars
Please only reply to this newsgroup. All mails would be bounced back.
August 4, 2004 at 6:13 am
Use DTS - create a new DTS package, create your first connection and point it to your data file, create your second connection and point it to your database then single click the textfile connection, hold down control key, single click the db connection, press right mouse button and select 'transform data task'.
Now an arrow appears between the two connections, double click the arrow and click the Transformations tab - you will see a graphical interface that will have 3 columns on the left and 3 arrows pointing to the first 3 columns on the right. Click Delete All, then click the first column on the left and the column you wish it to go to on the right, click New, then Copy Column and 'ok'. An arrow will appear to show the copy process between the two columns. Repeat for other two columns.
Close these windows then Run your DTS package.
Dave Hilditch
August 4, 2004 at 6:19 am
I was thinking of using T_SQL cause that the text file might change from time to time. Sometimes it might be six columns and perhaps 20. I was thinking of getting this information out of the text file - what fields it should be. So if BULK INSERT could let me place the field in the correct places - I would be delighted
-Lars
Please only reply to this newsgroup. All mails would be bounced back.
August 4, 2004 at 7:15 am
Use a FormatFile to specify the order and type of input data and in which columns to place the data. Note that any column not specified must be nullable.
BOL has details of FormatFiles, look up
bulk copy, format files, Using a Data File with Fewer Fields
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply