Reputation: 324
I am working on creating a front end for a role access management program. I need to figure out how to update a userName
that does not have a unique value. Also in the table it has a loweredUserName
column.
Here is my SQL statement:
UPDATE mssql_Users
SET UserName = @UserName,
LoweredUserName = LOWER(@UserName)
WHERE UserName = @UserName
So basically if there are multiple versions of the user name 'testUser'
I want to replace every instance of 'testUser'
with the new name of say 'userTest'
without having any other unique id
Upvotes: 0
Views: 60
Reputation: 10277
You will need two variables:
DECLARE @oldUserName varchar(200) = 'Old'
DECLARE @newUserName varchar(200) = 'New'
UPDATE mssql_Users
SET UserName = @newUserName,
LoweredUserName = LOWER(@newUserName)
WHERE UserName = @oldUserName
Upvotes: 1