Solved

data type conversion

Posted on 2008-06-17
8
176 Views
Last Modified: 2010-03-19
SqlServer
update   #Scorecard
set value = 'N/A' where value = ' '

This gives Error --
Error converting data type varchar to numeric.
pls someone give me a solution
0
Comment
Question by:sriramb69
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
8 Comments
 
LVL 2

Expert Comment

by:matty1stop
ID: 21802775
what is the datatype of your VALUE field?
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 43 total points
ID: 21802801
you cant assign a value like 'N/A' which is varchar, to a numeric field , so instead of updating the value field, you can display it as  'N/A'  while showing the values or else you can update as NULL

SqlServer
update   #Scorecard
set value =null  where value = ' '
0
 

Author Comment

by:sriramb69
ID: 21802821
data type of value field is int
0
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
LVL 2

Assisted Solution

by:matty1stop
matty1stop earned 86 total points
ID: 21802859
You can't assign a string like 'N/A' to an int field.  As the error message states it fails when it tries to convert 'N/A' to a type of int.
0
 

Author Comment

by:sriramb69
ID: 21802934
On the scorecard how do i display as 'n/a' where there is no value.
I want to only display and not update
0
 
LVL 2

Expert Comment

by:matty1stop
ID: 21802981
select isnull(value, 'N/A')
from #Scorecard
0
 
LVL 2

Assisted Solution

by:matty1stop
matty1stop earned 86 total points
ID: 21803085
That doesn't work.  try this:

select
isnull(cast(value as varchar(512)), 'N/A')
from #Scorecard
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question