Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Bulk insert and insert a date

Author  Topic 

pjnovak007
Starting Member

19 Posts

Posted - 2010-04-15 : 14:49:08
I am trying to do a bulk insert and the first field in the table I want to insert a static message. Can one of you masters help me:

BULK INSERT maindatetest
FROM 'c:\car\VINVENTORY_20100413094221.txt';
WITH
(
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n'
)


Field name in the table is (IMPORT_DATE)
value to insert is ('4/13/2010')



Patrick

pjnovak007
Starting Member

19 Posts

Posted - 2010-04-15 : 17:04:07
No one had an idea? :-)

Patrick
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2010-04-15 : 17:08:28
i don't think bulk insert does this. why don't you make a default value for IMPORT_DATE?

quote:
Originally posted by pjnovak007

I am trying to do a bulk insert and the first field in the table I want to insert a static message. Can one of you masters help me:

BULK INSERT maindatetest
FROM 'c:\car\VINVENTORY_20100413094221.txt';
WITH
(
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n'
)


Field name in the table is (IMPORT_DATE)
value to insert is ('4/13/2010')



Patrick

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-04-16 : 10:23:06
Omit that particular column during bulk insert
Refer http://beyondrelational.com/blogs/madhivanan/archive/2010/03/17/bulk-insert-to-table-with-specific-columns.aspx

Then update that column with static value

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

domano
Starting Member

1 Post

Posted - 2010-10-14 : 22:28:23
I am trying to do a bulk insert from a text file that looks as follows:

1,03312010,2,"1","MORRIS SHEPPARD TEXARKANA","TEXARKANA","TX",48,"75501",37,1,8360,"","419 W 4TH ST","4 ","J",7,1934,"06 ",0,1/1/1934 0:00:00,2,0

Is it possible to import without quotes when not all fields have quotes? I've been using Datawatch's Monarch software in a batch file to 'clean-up' the quotes, but would rather do it all within a SQL script.

David Shepard
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-10-26 : 08:59:27
You need to use format file
http://www.tek-tips.com/faqs.cfm?fid=1602

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -