Why does SQL Management Studio add cross-connect?

I sometimes need to run basic updates for the connection. For instance:

UPDATE t1 SET col1 = 'val1'
FROM table1 as t1
INNER JOIN table2 as t2
ON t1.ID = t2.t1_id
WHERE t2.col3 = 'val3'

This works fine, but for some reason in MS SQL Management Studio Express he wants to convert it to

UPDATE t1 SET col1 = 'val1'
FROM table1 as t1
INNER JOIN table2 as t2
ON t1.ID = t2.t1_id
CROSS JOIN t2
WHERE t2.col3 = 'val3'

For some reason, it adds a cross join that I don't understand.

Now my question is: why does Management Studio think that this is what I had in mind? It must have genuine application, otherwise he would not offer it. But I have no idea how and when (and why).

+3
source share
2 answers

MSDN , , . , -, - , , .

+1

, .

Try

t1 col1 = 'val1' 1 t1, table2 t2 t1.id = t2.t1_id t2.col3 = 'val3'

, . SQL-MS - ? ...

+2

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


All Articles