I am importing a TXT (tab) file into an SQL table.
Destination table is well over Varchar(1000) char in all the columns and value of that particular column has 800+ chars
So it looks like everything working fine, table has all the right data, but one column which usually has large string always truncated to 255
I'm using regular WriteToServer bcp command in the code
.NET ProgrammingMicrosoft SQL ServerMicrosoft SQL Server 2005
Last Comment
andreyATCr
8/22/2022 - Mon
Bob Learned
Are you importing the text file into a DataTable, and calling SqlBulkCopy.WriteToServer with that?
Bob
andreyATCr
ASKER
exactlly
andreyATCr
ASKER
Code:
OdbcDataAdapter da = new OdbcDataAdapter("Select * FROM " + name, conn);
//Retrieve the rows into a dataset from the text file
infoImportds = new DataSet();
da.Fill(infoImportds, "SourceTable");
DataTable infoImportdt = infoImportds.Tables[0];
sbc = new SqlBulkCopy(AppHelper.GetConfigValue(AppConstants.CNST_CONFIG_CONNECTION_STRING));
I don't think that the problem is with the SqlBulkCopy, but with the ODBC handling the text file.
Do you know how to check the length of the defined column for a DataTable?
Bob
andreyATCr
ASKER
I suspected this was a problem
I dont know how to check that
It's strange that ODBC limits this string length to 255
BTW, i'm using schema.ini to setup a few things
ColNameHeader=True
Format=TabDelimited
MaxScanRows=0
CharacterSet=ANSI
Are you saying that if i do NOT specify width for the column in schema.ini for that particular field of my TAB delimited file, it will default to 255 max?
Thank you
I do believe that I have seen 255 as a max, but for what I don't know. It would make sense, since 255 is the max size for a byte.
Bob
andreyATCr
ASKER
So i modified my code to specify all columns in schema.ini and set width of each to over 1000
Unfortunately the result hasnt changed
Data is being imported, but still 255
:(
andreyATCr
ASKER
I found solution
I used Memo Width vs. Text Width in ini file and it worked
Thank you for your help, you did lead me into it
Bob