---
title: "Excel导入Sqlserver中 混合字符的列 为空"
author: "李科笠"
date: "2014-04-14T17:10:31Z"
tags: []
categories: ["数据库"]
slug: "excel-sqlserver"
draft: false
lastmod: "2014-04-14T17:10:31Z"
id: 2045872
url: "https://likeli.iteye.com/blog/2045872"
---

Excel作为数据源导入到Sqlserver中的时候发现有的列中的某些值为空。

查看后发现，数字显示了，数字加字母的混合列就为空。

 

网上查了一下后，发现是因为Excel会自动判断当前导入列的格式，前8列中，出现的字符串的多，则保存为字符串，出现在数字多，则保存为整形。

 

解决方案，Excel强制转换数据类型。（图）

 

![](http://dl2.iteye.com/upload/attachment/0096/1000/c83d5272-6b5f-3cf5-bc23-e5f656bd77a8.jpg)  
 

![](http://dl2.iteye.com/upload/attachment/0096/1002/c4ac60a2-3c2b-389d-a5fe-bf2d61f9efde.jpg)  
 

![](http://dl2.iteye.com/upload/attachment/0096/1004/b2bba2d1-6871-38bd-93d3-53c6c3892e2f.jpg)  
 

![](http://dl2.iteye.com/upload/attachment/0096/1006/1b75fec3-0ceb-3f89-978e-698950feb285.jpg)  
 

![](http://dl2.iteye.com/upload/attachment/0096/1008/5381f283-f2fa-3fb2-9ac8-58650212085f.jpg)  
 

强制转换后每列中的数字前其实是加上了单引号，强制转换成文本。

之后，导入数据库，ok。完成