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)
 batch update with different value

Author  Topic 

wongz
Starting Member

6 Posts

Posted - 2003-10-27 : 20:46:32
Hi

I have a tblUser where i want to update the users password.I manage to write a code that randomly generate user password but i would like to update it to all the 1000 records. How can i do that, please help.

nr
SQLTeam MVY

12543 Posts

Posted - 2003-10-27 : 21:09:50
As you can't use a function use the unique field on the table (user_id?)

declare @pwd varchar(50)
declare @user_id int
select @user_id int
while @user_id < (select max(user_id) from tblUser)
begin
select @user_id = min(user_id) from tblUser where user_id > @user_id
exec s_GetPwd @pwd out
update tblUser set pwd = @pwd where user_id = @user_id
end


==========================================
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

wongz
Starting Member

6 Posts

Posted - 2003-10-27 : 21:25:57
thank you very much.....it works.. ^_^
Go to Top of Page
   

- Advertisement -