Solved

Conversion failed when converting the varchar value

Posted on 2015-02-11
3
177 Views
Last Modified: 2015-02-11
Dear Experts

select TKN_Dziennik from cdn.TKNag where TKN_Dziennik is not null union
select TrN_Dziennik from cdn.TraNag where TrN_Dziennik is not null union
select TrN_WsDziennik from cdn.TraNag where TrN_WsDziennik 

Open in new window


I got error in Sql Srv "Conversion failed when converting the varchar value 'ZK' to data type tinyint."
what should I do wrong?
do I need to use cast/convert in every line?

thanks
Jarek
0
Comment
Question by:ja-rek
3 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40603066
Since I don't see a CAST( as int) in here, then likely one or more of these objects is a view or table-valued function that has a CAST( as int) in it, and is failing there.
0
 
LVL 47

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40603103
You are UNION 3 columns and as result they should have the same datatype. Find which of the columns is TINYINT (TKN_Dziennik, TrN_Dziennik, TrN_WsDziennik) and apply a CAST function on it (CAST ColName AS VARCHAR)
0
 
LVL 1

Author Closing Comment

by:ja-rek
ID: 40603343
thanks for help!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

808 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