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
 Import/Export (DTS) and Replication (2000)
 Bulk insert field terminator

Author  Topic 

drman
Starting Member

38 Posts

Posted - 2002-06-27 : 11:35:41
in an article by Garth, he wrote the following statement to pull data into a temp file. It is assuming the file is structured as

"field1","field2","field3"

SET @SQL = "BULK INSERT TmpStList FROM '"+@PathFileName+"' WITH (FIELDTERMINATOR = '"",""') "

I will run into files to be imported that may be structured differently:
'field1','field2','field3' or
'field1';'field2';'field3' or
'field1'|'field2'|'field3' etc...

I set up a variable the represents the field terminator and am trying to pass it into the original statement, but I must be structuring it wrong.

@fieldterm = chr(34)+","+chr(34)

the statement would appear:

SET @SQL = "BULK INSERT TmpStList FROM '"+@PathFileName+"' WITH (FIELDTERMINATOR = '"+@fieldterm+"') "

Any idea what is wrong with this statement???



   

- Advertisement -