将varchar值'Email'转换为数据类型int时转换失败

时间:2019-08-30 17:50:04

标签: sql stored-procedures sqldatatypes

我有一个存储过程,该存储过程正在从其他一些数据库表中获取数据并将它们放入另一个表中。我遇到错误

  

将varchar值“ Email”转换为数据类型int时转换失败。

但是,我看不到在哪里/如何进行数据转换。

我已经检查了获取电子邮件地址的位置和插入电子邮件地址的数据类型。它们都设置为varchar(255)

DECLARE @prefix varchar(50), @middle varchar(50), @suffix varchar(50), 
        @companyID int, @companyNm varchar(100),
        @badge varchar(50), @title varchar(100), @salutation varchar(50), 
        @pplType int, @email varchar(255), @specialty int, 
        @mailpref int, @source int, 
        @add1 varchar(100), @add2 varchar(100), @city varchar(50), 
        @state varchar(50), @zip varchar(50), @countryID int, 
        @phone varchar(50), @ext varchar(50), @fax varchar(50), 
        @addID int, @addType int, @arrival datetime, @departure datetime, 
        @regType varchar(50), @mtRegID int

SELECT @regType = regType 
FROM Registration 
WHERE personID = @personID AND meetingCode = @meetingCode

SELECT 
    @prefix = [Name Prefix], @middle = Middle, @suffix = [Name Suffix], 
    @companyID = [Company ID], @companyNm = [Company Name], 
    @badge = [Badge Name], @title = Title, 
    @salutation = Salutation, @pplType = [People Type], 
    @email = Email, @specialty = [Specialty ID], @mailpref = MailPref, 
    @source = [Source ID] 
FROM  
    MeetingtrakTest.dbo.tblPeople 
WHERE 
    [Person ID] = @personID

SELECT 
    @add1 = Address1, @add2 = Address2, @city = City, @state = State, 
    @zip = Zip, @countryID = [Country Id],
    @phone = Phone, @ext = Extension, @fax = Fax, @addID = [Address ID] 
FROM 
    MeetingtrakTest.dbo.tblPeopleAddresses 
WHERE 
    [Person ID] = @personID AND [Primary] = 1

SELECT 
    @arrival = [Meeting Start Date], @departure = [Meeting End Date] 
FROM 
    MeetingtrakTest.dbo.tblMeetings 
WHERE 
    [Meeting Code] = @meetingCode

INSERT INTO tblRegistration ([Person Id], [Pre or On-Site], [Attendee List], [Use Company Name], [Reg Date], [Use Housing Costs], [Use Itinerary Costs], Attended, [Date Entered], [Entered By], [Date Updated], [First Name], [Last Name], [Meeting Code], [Registration Code], [Name Prefix], Middle, [Name Suffix], [Company ID], [Company Name], [Badge Name], Title, Salutation, [People Type], [Email], [Specialty ID], MailPref, Source, [Address 1], [Address 2], City, State, Zip, [Country ID], Phone, Extension, Fax, [Address Id] ,[Address Type], [Arrival Date], [Departure Date]) 
VALUES (@personID, 1, 1, 1, GETDATE(), 0, 0, 0, GETDATE(), 'etrak', GETDATE(), @first, @last, @meetingCode, @regType, @prefix, @middle, @suffix, @companyID, @companyNm, @badge, @title, @salutation, @pplType, @email, @specialty, @mailpref, @source, @add1, @add2, @city, @state, @zip, @countryID, @phone, @ext, @fax, @addID, @addType, @arrival, @departure); 

SET @mtRegID = SCOPE_IDENTITY();

0 个答案:

没有答案