• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 756
  • Last Modified:

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
0
barnesco
Asked:
barnesco
  • 2
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
what in case the phone number is  of the format  999-99999-999
0
 
derobyCommented:
Works fine here...

How did you declare the @StorePhone variable ?? Should be a varchar if the first thing you want to do is store  '(123)456-7891' into it
0
 
barnescoAuthor Commented:
It's a varchar (to accept all those parenthesis and dashes),  but the table is a bigint, which is why I'm converting it.
0
 
barnescoAuthor Commented:
I found it's another part of the query that's not working (not shown). Thanks for confirming the above worked.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now