How can we select two columns having different sorting

I have a SQL query like

SELECT Col1, Col2 FROM Table1 UNION ALL SELECT Col1, Col2 FROM Table2 

where col1 and col2 are strings and col2 are used.

When I run the request, it shows an error:

  • Cannot resolve collate conflict for column 1 in statement.
  • Cannot resolve collision conflict for column 2 in statement.

Someone please help.

+4
source share
1 answer

Is the error a case-sensitive difference between two tables? This is the mistake I most often saw.
If so, compare the offensive results table with the good old Latin1_General_CI_AS or others, which is most suitable.

For example, if table 1 is case sensitive, and you want to match both tables as if they were case insensitive:

 SELECT Col1 COLLATE Latin1_General_CI_AS, Col2 COLLATE Latin1_General_CI_AS FROM Table1 UNION ALL SELECT Col1, Col2 FROM Table2 
+6
source

Source: https://habr.com/ru/post/1344733/


All Articles