嗨,我已经为表 Persons 创建了一个存储过程,该表使用三个外键链接到这样的表地址:
-MaterialAddressID -HomeAddressID -PostalAddressID
这是我创建的存储过程:
-- =============================================
-- Author: *******************
-- Create date: 11.07.2013
-- Description: Gets User Personal Details
-- =============================================
ALTER PROCEDURE [eConnect].[GetUserPersonalDetails]
@personId int
AS
BEGIN
SELECT Persons.PersonalID,
Persons.FirstName ,
Persons.MiddleName ,
Persons.LastName ,
Persons.DateOfBirth,
Persons.CityOfBirth ,
Persons.BSN ,
Persons.SecondaryEmail ,
Persons.HomePhone ,
Persons.WorkPhone ,
Persons.MobilePhone,
MaterialAddress.StreetName ,
MaterialAddress.PostCode ,
MaterialAddress.City ,
HomeAddress.StreetName ,
HomeAddress.PostCode ,
HomeAddress.City ,
PostalAddress.StreetName ,
PostalAddress.PostCode ,
PostalAddress.City
FROM Sync_Persons as Persons
JOIN Sync_Addresses as MaterialAddress ON Persons.MaterialAddressID = MaterialAddress.AddressID
JOIN Sync_Addresses as HomeAddress ON Persons.HomeAddressID = HomeAddress.AddressID
JOIN Sync_Addresses as PostalAddress ON Persons.PostalAddressId = PostalAddress.AddressID
WHERE Persons.PersonalID = @personId
END
当我尝试执行此操作时,出现此错误:
消息 245,级别 16,状态 1,过程 GetUserPersonalDetails,第 11 行将 varchar 值“I-024800”转换为数据类型 int 时转换失败。
在这种情况下,第 11 行是: -- 描述:获取用户个人详细信息
为什么我在评论中收到错误,我该如何更正?