I have select like this:
SELECT isnull(table1.structure,'-')as structure1 FROM table1
and I get an error message:
Msg 8115, Level 16, State 6, Line 74
Arithmetic overflow error converting varchar to data type numeric.
Structure column is decimal type.
Why is this not allowed and what is the best solution?
My query in fact is much more complicated and I don't wan't to write a lot o
f corrections
Thank you,
Simon[quote from="Books Online"]
Syntax
ISNULL ( check_expression , replacement_value )
check_expression
Is the expression to be checked for NULL. check_expression can be of any
type.
replacement_value
Is the expression to be returned if check_expression is NULL.
replacement_value must have the same type as check_expresssion.
[/quote]
Your script should look like
[script]
select isnull(cast(@.d as varchar(40)),'-') as structure1 FROM table1
[/script]
Cristian Lefter, SQL Server MVP|||Because '-' is not a numeric value. Did you mean -1, or do you want to have
a dash in the output. Best practice would be to use the UI to do this, or
case table1.structure to a varchar value first. All depends on what your UI
is doing. By changing these to character strings, you might be messing up
what you are going to do with the data once you get it there.
----
Louis Davidson - drsql@.hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Blog - http://spaces.msn.com/members/drsql/
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)
"simon" <simon.zupan@.stud-moderna.si> wrote in message
news:eYrqV49HFHA.3336@.TK2MSFTNGP10.phx.gbl...
I have select like this:
SELECT isnull(table1.structure,'-')as structure1 FROM table1
and I get an error message:
Msg 8115, Level 16, State 6, Line 74
Arithmetic overflow error converting varchar to data type numeric.
Structure column is decimal type.
Why is this not allowed and what is the best solution?
My query in fact is much more complicated and I don't wan't to write a lot
of corrections
Thank you,
Simon
Tuesday, March 20, 2012
Converting
Labels:
converting,
database,
error,
isnull,
level,
messagemsg,
microsoft,
mysql,
oracle,
select,
server,
sql,
state,
structure,
structure1,
table1,
table1and,
thisselect
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment