Solved

SQL Conversion error

Posted on 2014-11-11
3
52 Views
Last Modified: 2014-11-20
When i run the following query i get an error: 'Conversion failed when converting the varchar value '%' to data type int.'

SELECT
      [FileCount] + '%'      
  FROM [Document]

How do i convert?
0
Comment
Question by:vbnetcoder
3 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40434803
By using either Cast or CONVERT - see http://technet.microsoft.com/en-us/library/aa226054(v=sql.80).aspx for more information.

SELECT CAST([FileCount] as varchar(16)) + "%"
  FROM [Document]

Open in new window

0
 
LVL 39

Expert Comment

by:lcohan
ID: 40435917
-- Or like below but mind you is the [FileCount] really a percentage or you need to calculate that

SELECT cast([FileCount] as sysname) + '%'  AS FileCount FROM [Document];
0
 

Author Closing Comment

by:vbnetcoder
ID: 40455371
ty
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sql Server group by 10 43
Whats wrong in this query - Select * from tableA,tableA 11 45
SQL - format decimal in a string 5 38
Accessing variables in MySQL query 4 25
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​

809 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