Error converting data type varchar to varbinary. MSSQL when converting to Integer
Date : March 29 2020, 07:55 AM
hop of those help? , Hex always have two characters. Try this create table hexvalue(Data varchar(10))
insert into hexvalue values('05'),('0E'),('12'),('17'),('15'),('EF'),('EF')
select convert(int, convert(varbinary, '0x'+Data, 1)) from hexvalue
|
Error converting data type varchar to numeric when converting substring to decimal
Date : March 29 2020, 07:55 AM
help you fix your problem Can you try this, SUBSTRING function can be used to extract number after character £. SELECT
ClientId
,Max(PayPeriod) As PeriodNo
,CASE WHEN MAX(Comment) like '%£%' THEN
CAST(SUBSTRING(MAX(Comment),2,LEN(MAX(Comment))) AS DECIMAL(18,2))
ELSE 0 END AS AvgEarnings2
FROM t_PayrollSSPEmployeeComment
WHERE comment like '%LEL%' AND comment like '%£%'
GROUP BY ClientID
|
Error converting data type varchar to date converting an int year into a string
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Check out DATEFROMPARTS (available from SQL 2012), and bypass strings altogether. SET @BeginDate = DATEFROMPARTS(@SchoolYear - 1, 1, 7)
|
Error converting data type nvarchar to numeric while converting phone number
Date : March 29 2020, 07:55 AM
wish of those help Your cast(([Insurance Phone]) as decimal won't work if there are dashes in the string. There is no reason to cast to a decimal before converting to varchar. If Insurance Phone is truly a varchar column, then there is a lot of unnecessary casting and converting in your query: INSERT INTO
PHONE_NUMBERS( [OWNER_ID]
, OWNER_TYPE_ID
, PHONE_NUMBER_TYPE_ID
, AREA_CODE
, PREFIX
, PHONE_NUMBER_BODY
, IS_ACTIVE
)
SELECT INS_COMPANY_ID
, @OWNER_TYPE_ID OWNER_TYPE_ID
, @PHONE_NUMBER_TYPE_ID PHONE_NUMBER_TYPE_ID
, LEFT([Insurance Phone], 3)
, substring( [Insurance Phone],4,3) PREFIX
, RIGHT([Insurance Phone],4)
, 1 IS_ACTIVE
FROM Insurance_Companies_28012020 EE
join INS_COMPANIES IC on ee.[Insurance Name] =IC.COMPANY_NAME where ic.is_active=1 and [Insurance Phone] is not null
|
SQL Server 2008: Error converting data type nvarchar to bigint when not converting anything
Date : March 29 2020, 07:55 AM
|