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)
 How To

Author  Topic 

ann
Posting Yak Master

220 Posts

Posted - 2006-07-30 : 15:04:35
Is it possible to do a sp where I retreive the value from one table to update another? Example, I have a table that has users and another that has branch info. I need to select the user branch from the users table, then grab the branch info from the branch table:
1.
Select branchNo from users where userID = blah....
2. Select * from branch where branchNo = branchNo

If it's possible, can anyone give me an example or direct me to where I can find more info on this?
Thanks

ann
Posting Yak Master

220 Posts

Posted - 2006-07-30 : 15:13:35
I think I found what I'm looking for:

USE pubs
SELECT pub_name
FROM publishers
WHERE pub_id IN
(SELECT pub_id
FROM titles
WHERE type = 'business')

Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-07-30 : 15:36:51
From your description it would be more like
select u.name, b.name
from users u
join branch b
on u.branchNo = b.branchNo

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -