Jump to content

SQL While Loop

- - - - -

  • Please log in to reply
1 reply to this topic

#1
stevie754

stevie754

    Programmer

  • Members
  • PipPipPipPip
  • 110 posts
Hi guys and girls,

Just need a little bit of help seeing why this code won't run for me.

declare @index integer
set @index = 1
While @index < 998
begin
update person
set password = 'Pass'
where userid = 'agent'@index
end

It is being run in DBVisualizer under the SQL Commander tab for a table that I want to assign a password to all the users. There are 997 agent user names and I want them all to share the same password as they currently don't have one defined and this will allow all users to sign in during my tests.

Please respond as quickly as possible.

Thanks Steve

#2
stevie754

stevie754

    Programmer

  • Members
  • PipPipPipPip
  • 110 posts
Nevermind got it working I had overcomplicated things. This worded for me

update person
set password = 'Pass'
where userid like 'agent%'




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users