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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Problem with Bulk insert

Author  Topic 

bubix
Starting Member

24 Posts

Posted - 2005-11-22 : 17:21:02
Hello,

I use the statement "Bulk insert" to insert data from a file to one table on
SQL Server.

I do like this:

bulk insert MyBase.dbo.Clients from 'D:\DataMyBase\TableClients.txt'
wiht (FieldSeparator = ',', Rowseparator='\n')

Table Clients(num int, name char(50), comment varchar(max))

But im my file "TableClients.txt", I have one row like this:

7,Peter,'Hello,World"\n

You can see, I want to use "," in my column comment but I have this message
error:
Type mismatch...

It's because I use "," in my comment and for statement "bulk insert", it's a
field terminator and then I have a number of colums different from my table
"Client".

How can do If I want use "," in my field???

nr
SQLTeam MVY

12543 Posts

Posted - 2005-11-22 : 20:30:21
It is a quote delimited field.
You can import into a single column table then extract using a function like
http://www.nigelrivett.net/SQLTsql/f_GetEntryDelimiitted.html
(or otherwise)
or you can use a format file to deal with quote delimited entries as in
http://www.nigelrivett.net/SQLTsql/BCP_quoted_CSV_Format_file.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -