将数据从excel工作表迁移到sql数据库表时出现此错误。以下是我的代码;
INSERT INTO Employee
( Emp_Prefix,EmpCardNumber, CostCenterCode, PayCenterCode, BasisOfPay, WorkingTime, BasisAmount, Title, Surname, First_Names,
Resident, Address, PostalAddress, Post_Code, Telephone, TelephoneOffice, TelephoneMobile, Sex, DOB, EmailAddress, EmailOffice, Nationality, Village, TAuthority,
District, Religion, DrivingLicenseNo, PassportNo, Marital_Status, Kin_Name, Kin_Relationship, Kin_Telephone, Spouse, Memo, Date_Joined, DesignationCode,
GradeCode, DepartmentCode, ConfirmedDate, Gratuity, GratuityRate, GratuityAmount, GratuityBalance, GratuityEffDate, Pensionable, PensionEffDate,
Payment_Method, Probation, ProbationEndDate, ContractStartDate, ContractEndDate, ETIN, EmployerContr, EmpContr, Status
)
SELECT 'P' as prifix, 0 as empcard, 'HO' AS COSTCENT,'OPM' as Paycent , 'M' AS BASICPAY, 1 AS WORKTIME,isnull( [Basic Salary] ,0) as Basicpay,isnull(Title,'') ,ISNULL(Surname,''),
isnull([First Name],''),'' AS RESID , isnull(Address,''), ISNULL(Address,'') AS POSTAD , '265' AS POSTCODE ,'' as Telephone ,'' AS OFFTEL ,'' as [Mobile Number] ,
ISNULL(Gender,''), isnull([Dat of Birth],'') as DOB ,'' as [Email Address] ,'' AS EMAILOFF ,'Malawian' as Nation ,'' as village ,'' as Tauth, '' as distr ,
'' as Relign , '' as drvlicen , '' as passport , ISNULL([Marriage Status],'') , '' as kinname , '' as KinRel , '' as Kin_Tel , '' as spouse ,'' as memo,
isnull( [Joined Date],'') as DateJoin ,'' as desig ,isnull([Grade Code],'') as Grdcode ,ISNULL(Department_Code,'') ,isnull( [Confirmed Data],'') as ConfDate ,0 as gartuity ,0 as GratRate, 0 as GratAmt , 0 as grabal , '' as GratDate,
CASE WHEN Pensionable ='Y' THEN 1 ELSE 0 END as pensio ,
'' as Pensdate , isnull([Pay Method],'') as PayMeth , '0' as Proba ,isnull( [Probation End Date],'') as probdate , '' as contractSTdate ,'' as contractEnddate ,'' as ETIN ,isnull([Company Contributin],'') as emplcontr ,isnull( [Employee Contribution],'') as Emplyecontr ,
'0' as statuss
FROM [dbo].[Sheet1$]
答案 0 :(得分:0)
Excel导入通常无法创建正确的列类型,并且空单元格变成空字符串”,其中您可能需要一个空数字。检查Sheet1 $表和Employee表的结构