简体   繁体   English

使用SQL查询文本文件会将大数字转换为NULL

[英]Querying text file with SQL converts large numbers to NULL

I am importing data from a text file and have hit a snag. 我正在从文本文件导入数据,但遇到了麻烦。 I have a numeric field which occasionally has very large values (10 billion+) and some of these values which are being converted to NULLs. 我有一个数字字段,偶尔会有非常大的值(超过100亿),并且其中一些值被转换为NULL。

Upon further testing I have isolated the problem as follows - the first 25 rows of data are used to determine the field size, and if none of the first 25 values are large then it throws out any value >= 2,147,483,648 (2^31) which comes after. 经过进一步测试,我将问题隔离如下-前25行数据用于确定字段大小,如果前25个值都不大,则会抛出任何大于等于2,147,483,648(2 ^ 31)的值紧接着。

I'm using ADO and the following connection string: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FILE_ADDRESS;Extended Properties=""text;HDR=YES;FMT=Delimited"" 我正在使用ADO和以下连接字符串:Provider = Microsoft.Jet.OLEDB.4.0; Data Source = FILE_ADDRESS; Extended Properties =“” text; HDR = YES; FMT = Delimited“”

Therefore, can anyone suggest how I can get round this problem without having to get the source data sorted descending on the large value column? 因此,有人可以建议我如何解决这个问题,而不必让源数据在大值列上降序排序? Is there some way I could define the data types of the recordset prior to importing rather than let it decide for itself? 有什么方法可以在导入之前定义记录集的数据类型,而不是让它自行决定?

Many thanks! 非常感谢!

You can use an INI file placed in the directory you are connecting to which describes the column types. 您可以使用放置在要连接的目录中的INI文件来描述列的类型。

See here for details: 详细信息请参见此处:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms709353(v=vs.85).aspx http://msdn.microsoft.com/zh-CN/library/windows/desktop/ms709353(v=vs.85).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM