Insert Data from CSV with more than 8000 characters

Answered Insert Data from CSV with more than 8000 characters

  • Tuesday, January 29, 2013 1:01 PM
     
     

    Hi ,

    I have a CSV file wehere in i am trying to import the data into SQL server 2008 R2 thru BCP command. I have few data which cross 8000 characters due to which i am getting truncation error. 

    Is their a way where i can insert data comming from CSV file with more than 8000 characters.

    Thanks,

    Santhosh


    Please have look on the comment

All Replies

  • Tuesday, January 29, 2013 2:34 PM
     
     Answered
    You can use the text data type to insert more than 8000 characters.
    • Marked As Answer by SanthoshH Thursday, January 31, 2013 5:05 AM
    •  
  • Tuesday, January 29, 2013 3:03 PM
     
     
    you can use varchar(max) datatype

    Thanks & Regards Prasad DVR

  • Tuesday, January 29, 2013 3:33 PM
     
     
    you can use varchar(max) datatype

    Thanks & Regards Prasad DVR

    varchar(max) in SQL Server 2008 R2 holds a maximum of 8000 characters...
  • Tuesday, January 29, 2013 6:03 PM
    Moderator
     
     
    That's not correct, varchar(max) can hold up to 2 GB of data.

    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog

  • Wednesday, January 30, 2013 5:32 AM
     
     

    Hey Naomi,

    I agree with ur reply but here my requirement is there are some data which crosses 8000 bytes , So Varchar(Max) nor the NVarchar(Max) wrks for this. SO i tries creating a table with datatype as NTEXT (Ntext becoz i may get a data of different languages) but if i create a format file for this table, even though i have used NText but within format files it is been taken as SALNCHAR with 8000 bytes as length.


    Please have look on the comment

  • Wednesday, January 30, 2013 9:30 PM
     
     

    I can't test this, because my employer doesn't allow SQL Server to be installed (I guess they don't trust it).  Anyway, take a look at this:

    http://weblogs.sqlteam.com/davidm/archive/2003/12/12/655.aspx

     I just stumbled across that while I was reading some articles about de-concatenating comma delimited strings.

    Hope it helps you out!!


    Ryan Shuell

    • Marked As Answer by SanthoshH Thursday, January 31, 2013 5:06 AM
    • Unmarked As Answer by SanthoshH Thursday, January 31, 2013 5:07 AM
    •  
  • Thursday, January 31, 2013 4:16 AM
     
     
    No, VARCHAR(8000) has a limit of 8000 characters. VARCHAR(MAX) has a storage limit of 2GB.
  • Thursday, January 31, 2013 4:18 AM
     
     Answered
    The text data type was deprecated in SQL 2005. The poster stated they're using SQL 2008 R2 so they should use VARCHAR(MAX) or NVARCHAR(MAX) if they need to store double-byte character data.
    • Marked As Answer by SanthoshH Thursday, January 31, 2013 5:06 AM
    •  
  • Thursday, January 31, 2013 4:27 AM