ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 275.4k

Conversion failed when converting the nvarchar value '/' to

Jun 4 2018 9:07 PM
I have SQL query as following :
  1. SELECT TOP (99.9999999) PERCENT CAST(CAST(LEFT(SpecialCode, CHARINDEX('/', SpecialCode) - 1) AS nvarchar) AS intAS Expr1, CAST(CAST(RIGHT(SpecialCode, CHARINDEX('/', SpecialCode) - 6) AS nvarchar) AS intAS Expr2, MemberCode, SpecialCode, StartingDate, JoinDate, EndDate, BirthDate, Name, FirstName, MiddleName, LastName, Nationality, Nationality2, Education, Address, City, Country, PostalCode,                           Homephone1, Homephone2, Workaddress, WorkPhone1, Ext1, WorkPhone2, Ext2, Mobile1, Mobile2, FaxNumber, Email, EmergencyTel, NoOfYearsTennis, ClubName, NationalRank, Year, class,                           NoOfYearsTournament, Note, MSRelation, RelatedMemberCode, MScategory, Member, ParentCard1, ParentCard2, ExpDate, position, worktype, NonActive, MSKind, MSType, CardNumber, CardReceived,                           Discount, Religious, Gender, Organization, RelatedMemberCodeOld, CreateUserId, CreateDateAndTime, UserId, DateAndTime, HasNotEmail, VillaOwner, Homephone3, Mobile3, Email2, Email3, BirthPlace,                           NationalNo, EndDateNationalNo, MiritialStatusID, WifeNo, GeneralAssembly FROM            dbo.Members WHERE (Member = 1) AND (SpecialCode IS NOT NULLORDER BY expr1, EXPR2  
Field SpecialCode found in Members Table and have values like that
 
006403/1 when i run query above it give me error
 
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '/' to data type int.
 
why and how to solve this error .

Answers (3)