Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Conversion failed when converting the varchar value

Posted on 2015-02-11
3
Medium Priority
?
217 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
[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
3 Comments
 
LVL 66

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 52

Accepted Solution

by:
Vitor Montalvão earned 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.

604 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