hi have created stored procedure table persons linked table address 3 foreign keys:
-materialaddressid -homeaddressid -postaladdressid
this stored procedure have create:
-- ============================================= -- author: ******************* -- create date: 11.07.2013 -- description: gets user personal details -- ============================================= alter procedure [econnect].[getuserpersonaldetails] @personid int 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 sync_persons persons join sync_addresses materialaddress on persons.materialaddressid = materialaddress.addressid join sync_addresses homeaddress on persons.homeaddressid = homeaddress.addressid join sync_addresses postaladdress on persons.postaladdressid = postaladdress.addressid persons.personalid = @personid end
when try exec error:
msg 245, level 16, state 1, procedure getuserpersonaldetails, line 11 conversion failed when converting varchar value 'i-024800' data type int.
line 11 in case : -- description: gets user personal details
why geting error @ comment , how can correct it?
try change line -
where cast(substring( persons.personalid, charindex('-', persons.personalid) + 1, len(persons.personalid) ) int) = @personid
or try -
where persons.personalid = 'i-' + cast(@personid varchar(10))
Comments
Post a Comment