bullk insert error

  • attempting to load data via a bulk insert

    declare @file varchar(1000)

    declare @loadTableName varchar(1000)

    declare @bulkLoad varchar(1000)

    -- read contents of file into the respected table

    --preset variable @loadTableName looks like: tlbCars

    --preset variable @file looks like: C:\localProjects\stest\cars.txt

    set @bulkLoad = 'bulk insert ' + @loadTableName + ' from "' + @file + '" with (fieldterminator = '|', rowterminator = ''' + char(10) + ''')'

    exec(@bulkLoad)

    the data in the cars.txt file looks like:

    1|toyota|tacoma

    1|toyota|tundra

    1|toyota|fjcruiser

    etc...

    Error:

    The data types varchar and varchar are incompatible in the '|' operator.

  • fixed it with: fieldterminator = ''|'',

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply