Link to home
Start Free TrialLog in
Avatar of barnesco
barnesco

asked on

Formatting CASE statement from VARCHAR to BIGINT

My case statement below formats well, however, I'd like to convert the varchar output into a bigint, but I'm not sure where I'm going wrong. I receive the error message: Error converting data type varchar to bigint.

SET @StorePhone = '(123)456-7891'

            StorePhone =      CASE SUBSTRING(@StorePhone, 1,1) WHEN '('
                                    THEN 111111111
                                    ELSE 222222222 END

Thanks
Avatar of Aneesh
Aneesh
Flag of Canada image

what in case the phone number is  of the format  999-99999-999
ASKER CERTIFIED SOLUTION
Avatar of deroby
deroby

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of barnesco
barnesco

ASKER

It's a varchar (to accept all those parenthesis and dashes),  but the table is a bigint, which is why I'm converting it.
I found it's another part of the query that's not working (not shown). Thanks for confirming the above worked.