Notice (8): file_put_contents(): Write of 274 bytes failed with errno=28 No space left on device [CORE/src/Log/Engine/FileLog.php, line 140]

Notice: file_put_contents() [function.file-put-contents]: Write of 1108 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): unserialize() [<a href='https://secure.php.net/function.unserialize'>function.unserialize</a>]: Error at offset 16363 of 16373 bytes [APP/Controller/NewsController.php, line 5571]

Notice: file_put_contents() [function.file-put-contents]: Write of 2761 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Undefined array key "nsort" [APP/Controller/NewsController.php, line 3613]

Notice: file_put_contents() [function.file-put-contents]: Write of 2075 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Trying to access array offset on value of type null [APP/Controller/NewsController.php, line 3613]

Notice: file_put_contents() [function.file-put-contents]: Write of 2099 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Undefined array key "nsort" [APP/Controller/NewsController.php, line 3613]

Notice: file_put_contents() [function.file-put-contents]: Write of 2075 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Trying to access array offset on value of type null [APP/Controller/NewsController.php, line 3613]

Notice: file_put_contents() [function.file-put-contents]: Write of 2099 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): SplFileObject::fwrite() [<a href='https://secure.php.net/splfileobject.fwrite'>splfileobject.fwrite</a>]: Write of 163 bytes failed with errno=28 No space left on device [CORE/src/Cache/Engine/FileEngine.php, line 141]

Notice: file_put_contents() [function.file-put-contents]: Write of 2792 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (512): long cache was unable to write '37279aa8d0ce67a7c41602f1e611fe53' to Cake\Cache\Engine\FileEngine cache [CORE/src/Cache/Cache.php, line 275]

Notice: file_put_contents() [function.file-put-contents]: Write of 2587 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): SplFileObject::fwrite() [<a href='https://secure.php.net/splfileobject.fwrite'>splfileobject.fwrite</a>]: Write of 121 bytes failed with errno=28 No space left on device [CORE/src/Cache/Engine/FileEngine.php, line 141]

Notice: file_put_contents() [function.file-put-contents]: Write of 2792 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (512): long cache was unable to write '2528562fdd0f8169b61c3e746e5c783e' to Cake\Cache\Engine\FileEngine cache [CORE/src/Cache/Cache.php, line 275]

Notice: file_put_contents() [function.file-put-contents]: Write of 2587 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
使用SqlBulkCopy时应注意Sqlserver表中使用缺省值的列 - 站长搜索
首页 > 资讯列表 > 编程/数据库 >>

使用SqlBulkCopy时应注意Sqlserver表中使用缺省值的列

Warning (2): Undefined array key "nsort" [ROOT/plugins/Kuhuang/templates/Websites/view.php, line 430]
Notice: file_put_contents() [function.file-put-contents]: Write of 2423 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Trying to access array offset on value of type null [ROOT/plugins/Kuhuang/templates/Websites/view.php, line 430]

Notice: file_put_contents() [function.file-put-contents]: Write of 2447 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
">
Warning (2): Undefined array key "nsort" [ROOT/plugins/Kuhuang/templates/Websites/view.php, line 430]

Notice: file_put_contents() [function.file-put-contents]: Write of 2423 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Trying to access array offset on value of type null [ROOT/plugins/Kuhuang/templates/Websites/view.php, line 430]

Notice: file_put_contents() [function.file-put-contents]: Write of 2447 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
2022-09-23 17:16:36 转载来源: 网络整理/侵权必删

SqlBulkCopy来自数据源的String类型的给定值不能转换为指定目标列的类型nvarchar。在网上找了下,大都说是因为数据库中的字段过小(来自数据源的String类型的给定值不能转换为指定目标列的类型nvarchar

SqlBulkCopy 来自数据源的 String 类型的给定值不能转换为指定目标列的类型 nvarchar。

image

在网上找了下,大都说是因为数据库中的字段过小(

来自数据源的 String 类型的给定值不能转换为指定目标列的类型 nvarchar。
),造成截断的错误导致,仔细检查后发现我的表设计中没有字段过小的情况,也不是单引号的问题。

后经仔细调试发现,由于使用SqlBulkCopy导入时我的文本文件与库中的表列不对应造成的。我的文本文件中有字段18个,而我的表中只使用了9个字段,且有两个是文本文件中没有的(即表结构1中的[Level]与[Cagegory]字段),由数据库填入默认值。表结构如下:

复制代码 代码如下:

表结构11
CREATE TABLE [dbo].[Ryxx](
[Name] [nvarchar](30) NOT NULL,
[IdCardNo] [nvarchar](30) NOT NULL,
[Sex] [nvarchar](2) NOT NULL,
[Height] [nvarchar](5) NULL,
[Level] [nvarchar](2) NULL, --默认为A
[Category] [nvarchar](20) NULL, --默认为“重点管理”
[Sponsor] [nvarchar](100) NULL,
[Contact] [nvarchar](30) NULL,
[Phone] [nvarchar](50) NULL,
[Number] [nvarchar](30) NULL

) ON [PRIMARY]

表结构1

修改后的表结构如下
复制代码 代码如下:

CREATE TABLE [dbo].[Ryxx](
[Name] [nvarchar](30) NOT NULL,
[IdCardNo] [nvarchar](30) NOT NULL,
[Sex] [nvarchar](2) NOT NULL,
[Height] [nvarchar](5) NULL,
[Sponsor] [nvarchar](100) NULL,
[Contact] [nvarchar](30) NULL,
[Phone] [nvarchar](50) NULL,
[Number] [nvarchar](30) NULL,
[Level] [nvarchar](2) NULL, --默认为A
[Category] [nvarchar](20) NULL --默认为“重点管理”
) ON [PRIMARY]

至此,问题解决。分析原因是因为从文本文件中获取的字段对应到表中缺省列中去了,产生了截断,想想使用bcp 时应该也会出现这样的错误。

标签: 使用 SqlBulkCopy 应注意 Sqlserver 表中 缺省


声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!

站长搜索

http://www.adminso.com

Copyright @ 2007~2025 All Rights Reserved.

Powered By 站长搜索

打开手机扫描上面的二维码打开手机版


使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

站长搜索目录系统技术支持