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 2005 Forums
 Transact-SQL (2005)
 Update

Author  Topic 

JeffS23
Posting Yak Master

212 Posts

Posted - 2008-01-06 : 19:08:41
I have two tables. one Named 'attachments' which has 3 fields that are relevant.

id - autonumber (unique)
userid - (id from 'users' table)
visible - bit

The other table is 'users', which has 3 relevant fields

userid - autonumber (unique) - key for the attachmets table
type - (nvarchar)

I need to update Attachments table and set visible = 0 when the userid joins the users table and the 'type' field of the 'users' table = 'corpuser'

I hope I explained myself.

nathans
Aged Yak Warrior

938 Posts

Posted - 2008-01-06 : 19:23:28
you can see such example in BOL.



update a
set visible = 0
from Attachments a
inner
join Users u on
a.UserID = u.UserID
where u.Type = 'corpuser'


Nathan Skerl
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-01-06 : 19:24:54
update attachments set a.visible = 0 from attachments a join users u on a.userid = u.userid where u.type = 'corpuser'

step behind.
Go to Top of Page
   

- Advertisement -