I have the following sql statement:
SELECT 1, 2, 3
UNION ALL
SELECT CAST(1 AS VARCHAR) + '%',CAST(2 AS VARCHAR) + '%',CAST(3 AS VARCHAR) + '%'
And I am getting the following error:
Conversion failed when converting the varchar value '1%' to data type int.
I could change the first select statement to ‘1’,’2′,’3′, but i have a many unions and only one row that has to have the percentage format. Is there any other alternatives that are available?
Thanks!
try this
Reason of error is you above select having 1,2,3 which is an integer values and you are doing union with the varchar value
so solution is you need to convert you above select data type to varchar
The second solution is