Sql server UPDATE combined with INNER JOIN with itself

I found a problem with the following UPDATE in my SQL SERVER

 UPDATE table_a SET table_a.More = -1 FROM table_a INNER JOIN ( SELECT column1, COUNT(*) AS More FROM table_a GROUP BY column1 ) AS table_b ON table_a.column1 = table_b.column1 

Note that the INNER JOIN part uses this table. After this UPDATE I expect some lines to have More equal to -1 . But I only got 1 s. I am 100% sure that column1 has duplicates. What am I missing?

The problem I found out about is that some guy defined the More column as a bit type!

+6
source share
1 answer

I have a problem here in the data type, in the bit type you can only have 1 or 0 or NULL. Change data type to int

+1
source

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


All Articles