By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,265 Members | 1,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,265 IT Pros & Developers. It's quick & easy.

UPDATE makes cells NULL

P: 6
Hi,

I'm trying to update a coloumn in table A with the corresponding values in table B. It updates the values correctly for the rows that meet the criteria, but changes the values of other rows to NULL.

update ALTMALZEME
set PROJEKODU = (select YENIPROJE from SevkiyatTMP WHERE SevkiyatTMP.MALZEMENO = ALTMALZEME.ALTMPKOD)

the Select command works fine and selects the needed rows, but the remaining rows get the value NULL in the coloumn PROJEKODU.

How can i exclude the remaining rows?

Thanks
Feb 16 '10 #1
Share this Question
Share on Google+
3 Replies


P: 6
update ALTMALZEME
set PROJEKODU = SevkiyatTMP.YENIPROJE
FROM dbo.ALTMALZEME INNER JOIN dbo.SevkiyatTMP
ON dbo.ALTMALZEME.ALTMPKOD = dbo.SevkiyatTMP.MALZEMENO

This solved my problem :)
Feb 16 '10 #2

OraMaster
100+
P: 135
Hello

Slight modification in your update query

update ALTMALZEME
set PROJEKODU = SevkiyatTMP.YENIPROJE
FROM dbo.ALTMALZEME INNER JOIN dbo.SevkiyatTMP
ON dbo.ALTMALZEME.ALTMPKOD = dbo.SevkiyatTMP.MALZEMENO
WHERE PROJEKODU <> SevkiyatTMP.YENIPROJE

Since I think there is no point in updating the column value with same value.
Feb 19 '10 #3

P: 6
Thanx for the advice OraMaster, you are right about the point but there will not be such possibility. The new value will always be different. But thanx for reminding, will be handy somewhere else ;)

thanx
Engin
Feb 21 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.