I have 2 table in a ms sql database prod_curs_test and rebuturi_test.
I want to update some fields in prod_curs_test with data from rebuturi_test. I used this to do that:

update dbo.prod_curs_test
set dbo.prod_curs_test.cant_rebuturi = (SELECT     dbo.rebuturi_test.Cantitate
FROM         dbo.rebuturi_test CROSS JOIN
                      dbo.prod_curs_test
WHERE     dbo.rebuturi_test.Comanda = dbo.prod_curs_test.Comanda)
where exists (SELECT     dbo.rebuturi_test.Cantitate
FROM         dbo.rebuturi_test CROSS JOIN
                      dbo.prod_curs_test
WHERE     dbo.rebuturi_test.Comanda = dbo.prod_curs_test.Comanda)

But it returns this error:

"Msg 512, Level 16, State 1, Line 2
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

(0 row(s) affected)"

What I did wrong??

Tnx for any suggestion.

It has been solved, somebody please close the topic.

Can you please share solution with us? It may help somebody with similar problem in the future...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.