I have SQL query as following :
- SELECT TOP (99.9999999) PERCENT CAST(CAST(LEFT(SpecialCode, CHARINDEX('/', SpecialCode) - 1) AS nvarchar) AS int) AS Expr1, CAST(CAST(RIGHT(SpecialCode, CHARINDEX('/', SpecialCode) - 6) AS nvarchar) AS int) AS 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 NULL) ORDER 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 .
Bryian TanPosted Jun 4, 2018, 11:27 PM
Here how I replicate the error.
Msg 245, Level 16, State 1, Line 3
ahmed elbarbaryPosted Jun 4, 2018, 11:21 PM
Nitin SontakkePosted Jun 4, 2018, 10:11 PM