Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 update query

Author  Topic 

desikankannan
Posting Yak Master

152 Posts

Posted - 2008-04-03 : 08:27:13
hi,
i try to update first two rows based on the conditions but its not wroking
UPDATE tblautogen SET fldactive = 'Y' from (SELECT TOP 2 fldcouponno FROM tblautogen WHERE fldccode = 'D') tblautogen

shows the error Invalid column name 'fldactive' but i have this field fldactive

Desikankannan

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-03 : 08:31:10
[code]Update t1
set fldactive = 'Y'
From tblautogen t1 JOIN
(SELECT TOP 2 fldcouponno FROM tblautogen WHERE fldccode = 'D') T2
ON T1.fldcouponno = T2.fldcouponno[/code]

or

[code]SET ROWCOUNT 2

UPDATE tblautogen
SET fldactive = 'Y'
WHERE fldccode = 'D'

SET ROWCOUNT 0[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -