Solved

data type conversion

Posted on 2008-06-17
8
173 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
  • 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now