Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. BULK INSERT and collation problem

BULK INSERT and collation problem

Scheduled Pinned Locked Moved Database
helpdatabasequestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    msx23
    wrote on last edited by
    #1

    I'm trying to use BULK INSERT to import a text file and then check its contents against a table in the database. I'm getting a problem when I compare the results however. I'm making a temp table to hold the text file's contents

    CREATE TABLE #Temp(Code varchar(5), number varchar(2))

    Then using BULK INSERT to get the contents in

    BULK INSERT #Temp FROM 'PATH.txt' WITH (FIELDTERMINATOR = ',',ROWTERMINATOR = '\n')

    And then checking if any matches occur

    SELECT Code, (CASE WHEN
    (SELECT Count(DBTable.Code) From DBTableWHERE DBTable.Code= #Temp.Code) > 0
    THEN "Yes"
    ELSE "No" END) AS FLAG
    From #TempCCServs

    The problem is that I get the following error message now: "Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation." Anyone have an idea what I'm doing wrong? Thanks for any help.

    S 1 Reply Last reply
    0
    • M msx23

      I'm trying to use BULK INSERT to import a text file and then check its contents against a table in the database. I'm getting a problem when I compare the results however. I'm making a temp table to hold the text file's contents

      CREATE TABLE #Temp(Code varchar(5), number varchar(2))

      Then using BULK INSERT to get the contents in

      BULK INSERT #Temp FROM 'PATH.txt' WITH (FIELDTERMINATOR = ',',ROWTERMINATOR = '\n')

      And then checking if any matches occur

      SELECT Code, (CASE WHEN
      (SELECT Count(DBTable.Code) From DBTableWHERE DBTable.Code= #Temp.Code) > 0
      THEN "Yes"
      ELSE "No" END) AS FLAG
      From #TempCCServs

      The problem is that I get the following error message now: "Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation." Anyone have an idea what I'm doing wrong? Thanks for any help.

      S Offline
      S Offline
      Syed Mehroz Alam
      wrote on last edited by
      #2

      The two columns in the comparison differ in collation settings. The following code applies sames collation to both sides before the comparison. SELECT Count(DBTable.Code) From DBTable WHERE DBTable.Code collate Latin1_General_CI_AS = #Temp.Code collate Latin1_General_CI_AS Hope that helps. Regards, Syed Mehroz Alam

      My Articles

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups