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
 General SQL Server Forums
 New to SQL Server Programming
 Set bit field in one table according to existence

Author  Topic 

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-08-29 : 12:06:34
I have two tables. Table_a has rows that are uniquely identified by an ECSOID value. there is a bit field in that table called "Arrest". That bit field needs to be set to 1 if the ecsoid for that row exists in another table (table_b). My assumption wast that i would be doing an innerjoin between the two tables on the existence of the ECSOID in table_b, similar to:


Update a
Set a.arrest = 1
From Table_b
Inner Join table_a
where a.ecsoid in(select ECSOID in Tables.dbo.Table_b)


obviously, the above isn't working or i would not be here.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-08-29 : 12:15:04
Update a
Set arrest = 1
From Table_b b
Join table_a a
on a.ecsoid = b.ECSOID

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-08-29 : 12:22:36
ok. so why not "inner join"?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-08-29 : 12:25:15
It is an inner join. You just don't have to type inner. Just specifying join equals inner join. Just like just specifying left join equals left outer join. So there are shortcuts built into the language.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-08-29 : 14:31:52
thanks!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-08-29 : 15:01:47
You're welcome, glad to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -