Sunday, March 11, 2012

Error converting data type varchar to numeric

Hello:
I'm getting the famous "Error converting data type varchar to numeric" error
upon using an If, then statement.
I'm not too familiar with the use of CAST or CONVERT, which I understand
eliminates this sort of error.
How do I use either of those terms in the following SELECT CASE statement:
CASE UPR30300.PAYROLCD WHEN 'BREVN' THEN UPR40600.DSCRIPTN
WHEN 'OVTMN' THEN UPR40600.DSCRIPTN WHEN 'BNDIS' THEN UPR40600.DSCRIPTN WHEN
'BNSHR' THEN UPR40600.DSCRIPTN
ELSE '0' END As [Payroll Description]
I don't get why SQL thinks I'm trying to do something numeric. All of the
fields in the above statement are string--not numeric. I don't know nuttin'
'bout no numbers!
Thanks!
childofthe1980sPlease don't multi-post. See answer in .programming.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
"childofthe1980s" <childofthe1980s@.discussions.microsoft.com> wrote in
message news:910EE9BB-3328-432C-9BC6-B06BF2C558CD@.microsoft.com...
Hello:
I'm getting the famous "Error converting data type varchar to numeric" error
upon using an If, then statement.
I'm not too familiar with the use of CAST or CONVERT, which I understand
eliminates this sort of error.
How do I use either of those terms in the following SELECT CASE statement:
CASE UPR30300.PAYROLCD WHEN 'BREVN' THEN UPR40600.DSCRIPTN
WHEN 'OVTMN' THEN UPR40600.DSCRIPTN WHEN 'BNDIS' THEN UPR40600.DSCRIPTN WHEN
'BNSHR' THEN UPR40600.DSCRIPTN
ELSE '0' END As [Payroll Description]
I don't get why SQL thinks I'm trying to do something numeric. All of the
fields in the above statement are string--not numeric. I don't know nuttin'
'bout no numbers!
Thanks!
childofthe1980s|||I have to multi-post, or I don't get an answer.
There is no answer over at the other section either, Tom--just a request to
post data which I cannot post.
This is ridiculous.
childofthe1980s
"Tom Moreau" wrote:

> Please don't multi-post. See answer in .programming.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
> "childofthe1980s" <childofthe1980s@.discussions.microsoft.com> wrote in
> message news:910EE9BB-3328-432C-9BC6-B06BF2C558CD@.microsoft.com...
> Hello:
> I'm getting the famous "Error converting data type varchar to numeric" err
or
> upon using an If, then statement.
> I'm not too familiar with the use of CAST or CONVERT, which I understand
> eliminates this sort of error.
> How do I use either of those terms in the following SELECT CASE statement:
> CASE UPR30300.PAYROLCD WHEN 'BREVN' THEN UPR40600.DSCRIPTN
> WHEN 'OVTMN' THEN UPR40600.DSCRIPTN WHEN 'BNDIS' THEN UPR40600.DSCRIPTN WH
EN
> 'BNSHR' THEN UPR40600.DSCRIPTN
> ELSE '0' END As [Payroll Description]
> I don't get why SQL thinks I'm trying to do something numeric. All of the
> fields in the above statement are string--not numeric. I don't know nutti
n'
> 'bout no numbers!
> Thanks!
> childofthe1980s
>
>|||Help us help you:
http://www.aspfaq.com/etiquette.asp?id=5006
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
"childofthe1980s" <childofthe1980s@.discussions.microsoft.com> wrote in
message news:BA8EFDC4-B4C3-4635-931F-90539E6DB06F@.microsoft.com...
I have to multi-post, or I don't get an answer.
There is no answer over at the other section either, Tom--just a request to
post data which I cannot post.
This is ridiculous.
childofthe1980s
"Tom Moreau" wrote:

> Please don't multi-post. See answer in .programming.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
> "childofthe1980s" <childofthe1980s@.discussions.microsoft.com> wrote in
> message news:910EE9BB-3328-432C-9BC6-B06BF2C558CD@.microsoft.com...
> Hello:
> I'm getting the famous "Error converting data type varchar to numeric"
> error
> upon using an If, then statement.
> I'm not too familiar with the use of CAST or CONVERT, which I understand
> eliminates this sort of error.
> How do I use either of those terms in the following SELECT CASE statement:
> CASE UPR30300.PAYROLCD WHEN 'BREVN' THEN UPR40600.DSCRIPTN
> WHEN 'OVTMN' THEN UPR40600.DSCRIPTN WHEN 'BNDIS' THEN UPR40600.DSCRIPTN
> WHEN
> 'BNSHR' THEN UPR40600.DSCRIPTN
> ELSE '0' END As [Payroll Description]
> I don't get why SQL thinks I'm trying to do something numeric. All of the
> fields in the above statement are string--not numeric. I don't know
> nuttin'
> 'bout no numbers!
> Thanks!
> childofthe1980s
>
>|||"childofthe1980s" <childofthe1980s@.discussions.microsoft.com> wrote in
message news:BA8EFDC4-B4C3-4635-931F-90539E6DB06F@.microsoft.com...
>I have to multi-post, or I don't get an answer.
> There is no answer over at the other section either, Tom--just a request
> to
> post data which I cannot post.
Don't MULTI-post, CROSS-post. (and only then to a select number of groups).

>
Greg Moore
SQL Server DBA Consulting
Email: sql (at) greenms.com http://www.greenms.com

No comments:

Post a Comment