Solved

Conversion failed when converting the varchar value

Posted on 2015-02-11
3
175 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 45

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

757 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

22 Experts available now in Live!

Get 1:1 Help Now