Error converting data type varchar to numeric |
|
Author |
Message |
Isadore
|
Posted: Sun Mar 18 20:35:49 CDT 2007 |
Top |
SQL Server Developer >> 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]
Thanks!
childofthe1980s
SQL Server94
|
|
|
|
|
Tom
|
Posted: Sun Mar 18 20:35:49 CDT 2007 |
Top |
SQL Server Developer >> Error converting data type varchar to numeric
How about posting the DDL for the UPR30300 and UPR40600 tables?
--
Tom
----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
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]
Thanks!
childofthe1980s
|
|
|
|
|
childofthe1980s
|
Posted: Sun Mar 18 20:44:03 CDT 2007 |
Top |
SQL Server Developer >> Error converting data type varchar to numeric
Hi Tom:
Hmm...I'm not sure how to post this. All of the characters types within the
formula that I posted were string characters. I'm sorry. I'm not sure what
else to post, really.
childofthe1980s
> How about posting the DDL for the UPR30300 and UPR40600 tables?
>
> --
> Tom
>
> ----------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
>
> 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]
>
> Thanks!
>
> childofthe1980s
>
>
>
|
|
|
|
|
Tom
|
Posted: Sun Mar 18 21:01:47 CDT 2007 |
Top |
SQL Server Developer >> Error converting data type varchar to numeric
Please post the CREATE TABLE statements for the tables involved. If you
have sample data, that would help, too.
--
Tom
----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
Hi Tom:
Hmm...I'm not sure how to post this. All of the characters types within the
formula that I posted were string characters. I'm sorry. I'm not sure what
else to post, really.
childofthe1980s
> How about posting the DDL for the UPR30300 and UPR40600 tables?
>
> --
> Tom
>
> ----------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
>
> 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]
>
> Thanks!
>
> childofthe1980s
>
>
>
|
|
|
|
|
childofthe1980s
|
Posted: Sun Mar 18 21:37:03 CDT 2007 |
Top |
SQL Server Developer >> Error converting data type varchar to numeric
Boy, I don't know how to do any of that.
I'll have to check another avenue.
Thanks, anyway
childofthe1980s
> Please post the CREATE TABLE statements for the tables involved. If you
> have sample data, that would help, too.
>
> --
> Tom
>
> ----------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
>
> Hi Tom:
>
> Hmm...I'm not sure how to post this. All of the characters types within the
> formula that I posted were string characters. I'm sorry. I'm not sure what
> else to post, really.
>
> childofthe1980s
>
>
> > How about posting the DDL for the UPR30300 and UPR40600 tables?
> >
> > --
> > Tom
> >
> > ----------------------------------------------------
> > Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> > SQL Server MVP
> > Toronto, ON Canada
> >
> > 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]
> >
> > Thanks!
> >
> > childofthe1980s
> >
> >
> >
>
>
>
|
|
|
|
|
Tom
|
Posted: Sun Mar 18 21:43:30 CDT 2007 |
Top |
SQL Server Developer >> Error converting data type varchar to numeric
Well, you had to create the table somehow. How about right-clicking on the
table, and clicking on Script table as...
--
Tom
----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
Boy, I don't know how to do any of that.
I'll have to check another avenue.
Thanks, anyway
childofthe1980s
> Please post the CREATE TABLE statements for the tables involved. If you
> have sample data, that would help, too.
>
> --
> Tom
>
> ----------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
>
> Hi Tom:
>
> Hmm...I'm not sure how to post this. All of the characters types within
> the
> formula that I posted were string characters. I'm sorry. I'm not sure
> what
> else to post, really.
>
> childofthe1980s
>
>
> > How about posting the DDL for the UPR30300 and UPR40600 tables?
> >
> > --
> > Tom
> >
> > ----------------------------------------------------
> > Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> > SQL Server MVP
> > Toronto, ON Canada
> >
> > 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]
> >
> > Thanks!
> >
> > childofthe1980s
> >
> >
> >
>
>
>
|
|
|
|
|
Rahul
|
Posted: Sun Mar 18 23:56:49 CDT 2007 |
Top |
SQL Server Developer >> Error converting data type varchar to numeric
> Well, you had to create the table somehow. How about right-clicking on the
> table, and clicking on Script table as...
>
> --
> Tom
>
> ----------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
>
> Boy, I don't know how to do any of that.
>
> I'll have to check another avenue.
>
> Thanks, anyway
>
> childofthe1980s
>
>
>
> > Please post the CREATE TABLE statements for the tables involved. If you
> > have sample data, that would help, too.
>
> > --
> > Tom
>
> > ----------------------------------------------------
> > Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> > SQL Server MVP
> > Toronto, ON Canada
>
> > Hi Tom:
>
> > Hmm...I'm not sure how to post this. All of the characters types within
> > the
> > formula that I posted were string characters. I'm sorry. I'm not sure
> > what
> > else to post, really.
>
> > childofthe1980s
>
>
> > > How about posting the DDL for the UPR30300 and UPR40600 tables?
>
> > > --
> > > Tom
>
> > > ----------------------------------------------------
> > > Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> > > SQL Server MVP
> > > Toronto, ON Canada
>
> > > 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]
>
> > > Thanks!
>
> > > childofthe1980s- Hide quoted text -
>
> - Show quoted text -
Hi,
Use it ---
CASE Cast(UPR30300.PAYROLCD as Char(5))
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]
Rahul
|
|
|
|
|
|
|