I am stuck on converting a varchar
column UserID
to INT
. I know, please don\'t ask why this UserID
column was not created as
This is more for someone Searching for a result, than the original post-er. This worked for me...
declare @value varchar(max) = 'sad';
select sum(cast(iif(isnumeric(@value) = 1, @value, 0) as bigint));
returns 0
declare @value varchar(max) = '3';
select sum(cast(iif(isnumeric(@value) = 1, @value, 0) as bigint));
returns 3