本文介绍了列名或提供的值数与表定义不匹配。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
StudentTable
CREATE TABLE [学生]。[StudentDetails](
[StudentId] [int] IDENTITY(1,1)NOT NULL,
[名称] [varchar](35)NULL,
[IDNo] [varchar](10)NULL,
[NameofGuardian] [varchar](50)NULL,
[AddressofCommunication] [ varchar](200)NULL,
[MobileNumber] [varchar](50)NULL,
[LandlineNumber] [varchar](20)NULL,
[电子邮件] [varchar](50) NULL,
[AdmissionYear] [varchar](20)NULL,
[SectionID] [int] NULL,
[ClassID] [int] NULL,
[IsActive] [bit ] NULL,
[IsDeleted] [bit] NULL,
[CreatedBy] [int] NULL,
[CreationDate] [datetime] NULL,
[ModifiedBy] [int] NULL ,
[ModifiedDate] [datetime] NULL
)
USER DEFINED TABLE TYPE
CREATE TYPE [Student]。[InsertBulkType] AS TABLE(
[Name] [varchar](35)NULL,
[IDNo] [varchar](10)NULL,
[NameofGuardian] [varchar](50)NULL,
[AddressofCommunication] [varchar](200)NULL,
[MobileNu mber] [varchar](50)NULL,
[LandlineNumber] [varchar](20)NULL,
[电子邮件] [varchar](50)NULL,
[AdmissionYear] [varchar] (20)NULL,
[SectionID] [int] NULL,
[ClassID] [int] NULL
)
当我为下面的批量插入创建程序时出现错误
这是我的程序
创建程序[学生]。[InsertBulkStudent ]
@tblStudent InsertBulkType READONLY
AS
BEGIN
INSERT INTO StudentDetails
SELECT Name,IDNo,NameofGuardian,AddressofCommunication ,MobileNumber,LandlineNumber,
电子邮件,AdmissionYear,SectionID,ClassID
来自@tblStudent
结束
错误是
消息213,级别16,状态1,过程InsertBulkStudent,第9行
列名或提供的值的数量与表不匹配定义。
我尝试过:
消息213,级别16 ,状态1,过程InsertBulkStudent,第9行
列名或提供的值与表定义不匹配。
解决方案
StudentTable
CREATE TABLE [Student].[StudentDetails]( [StudentId] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](35) NULL, [IDNo] [varchar](10) NULL, [NameofGuardian] [varchar](50) NULL, [AddressofCommunication] [varchar](200) NULL, [MobileNumber] [varchar](50) NULL, [LandlineNumber] [varchar](20) NULL, [Email] [varchar](50) NULL, [AdmissionYear] [varchar](20) NULL, [SectionID] [int] NULL, [ClassID] [int] NULL, [IsActive] [bit] NULL, [IsDeleted] [bit] NULL, [CreatedBy] [int] NULL, [CreationDate] [datetime] NULL, [ModifiedBy] [int] NULL, [ModifiedDate] [datetime] NULL )
USER DEFINED TABLE TYPE
CREATE TYPE [Student].[InsertBulkType] AS TABLE( [Name] [varchar](35) NULL, [IDNo] [varchar](10) NULL, [NameofGuardian] [varchar](50) NULL, [AddressofCommunication] [varchar](200) NULL, [MobileNumber] [varchar](50) NULL, [LandlineNumber] [varchar](20) NULL, [Email] [varchar](50) NULL, [AdmissionYear] [varchar](20) NULL, [SectionID] [int] NULL, [ClassID] [int] NULL )
when i create procedure for bulk insert below error came
this is my procedure
Create PROCEDURE [Student].[InsertBulkStudent] @tblStudent InsertBulkType READONLY AS BEGIN INSERT INTO StudentDetails SELECT Name,IDNo,NameofGuardian,AddressofCommunication,MobileNumber,LandlineNumber, Email,AdmissionYear,SectionID,ClassID FROM @tblStudent end
error is
Msg 213, Level 16, State 1, Procedure InsertBulkStudent, Line 9 Column name or number of supplied values does not match table definition.
What I have tried:
Msg 213, Level 16, State 1, Procedure InsertBulkStudent, Line 9 Column name or number of supplied values does not match table definition.
解决方案
这篇关于列名或提供的值数与表定义不匹配。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!