Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL SP Error 213

Status
Not open for further replies.

WordTechinc

Programmer
Sep 4, 2009
38
Error 213: Insert Error: Column name or number of supplies values does not match table definition. Insert Error: Column name or number of supplies values does not match table definition.

I am getting Error 213 after add ClassKey Varcgar(20)in table @LicenseID_ProfCode. Please help me.




Declare @LicenseID_ProfCode table
(
LicenseID numeric(11),
RankOrder int,
ProfCode char(4),
StudentID numeric(18),
ZipCode Varchar(10),
ClassKey NVARCHAR(20)
)


Insert into @LicenseID_ProfCode (LicenseID,StudentID,ProfCode,RankOrder,ZipCode,ClassKey)
SELECT DISTINCT LicenseMaster.LicenseID,LicenseMaster.StudentID,INRv2_ProfCodeRelation.ProfCode,RankOrder,LicenseMaster.ZipCode,INR_Attendee.ClassKey
From [INR_LicenseMaster] LicenseMaster
INNER JOIN INR_Attendee ON left(LicenseMaster.zipcode,5) = left(INR_Attendee.zipcode,5)
INNER JOIN @ClassTab ClassTab ON INR_Attendee.ClassKey = ClassTab.ClassKey
INNER JOIN @SSCodeTab SSCodeTab ON LicenseMaster.state = SSCodeTab.SSCode
INNER JOIN @INRV2_LicenseStatus LicenseStatus
ON LicenseStatus.status=LicenseMaster.LicStatus
INNER JOIN @NCOAHitCodeTAB NCOAHitCodeTAB
ON NCOAHitCodeTAB.NCOAHitCode=ISNULL(LicenseMaster.NCOAHitCode,'M')
INNER JOIN
INRv2_ProfCodeRelation
ON LicenseMaster.LicenseID=INRv2_ProfCodeRelation.LicenseID
INNER JOIN
INR_ProfCodeMaster
ON INRv2_ProfCodeRelation.ProfCode=INR_ProfCodeMaster.ProfCode
INNER JOIN INR_Terms T ON INRv2_ProfCodeRelation.DSCode=T.DSCode AND INRv2_ProfCodeRelation.TimesUsed < T.NoOfuses AND GetDate() < T.ExpirationDate
WHERE
DPBC is not null and (NeverUSA <> 'N'or NeverUSA is null)
and UsedStatus='Y'
order by LicenseMaster.LicenseID
 
I am sorry there is typing error. ClassKey is Varchar(20)
I also tried Classkey Nvarchar(20) and got same Error 213

INR_Attendee.ClassKey = Nvarchar(20)
DECLARE @ClassTab TABLE(ClassKey NVARCHAR(20))



Declare @LicenseID_ProfCode table
(
LicenseID numeric(11),
RankOrder int,
ProfCode char(4),
StudentID numeric(18),
ZipCode Varchar(10),
ClassKey VARCHAR(20)
)
 
I cannot replicate the problem. I simplified the script to this:
Code:
DECLARE @ClassTab TABLE(ClassKey NVARCHAR(20)) 
insert @ClassTab values ('class 1')
insert @ClassTab values ('class 2')
insert @ClassTab values ('class 3')

Declare @LicenseID_ProfCode table
(      
 LicenseID numeric(11),      
 RankOrder int,      
 ProfCode char(4),      
 StudentID numeric(18),       
 ZipCode Varchar(10),
 ClassKey NVARCHAR(20)
)       
      
Insert into @LicenseID_ProfCode (LicenseID,StudentID,ProfCode,RankOrder,ZipCode,ClassKey)    SELECT DISTINCT 1, 2, 'prof', 3, 'zip', ClassKey
  FROM @ClassTab
 
select * from @LicenseID_ProfCode
And it returned results as expected:
Code:
LicenseID RankOrder ProfCode StudentID ZipCode ClassKey
        1         3 prof             2 zip     class 1
        1         3 prof             2 zip     class 2
        1         3 prof             2 zip     class 3
Is there something unusual about one of the tables that I have removed?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top