Taken from forums some time ago. Don't remember the author and not tested yet
declare @oldName nvarchar(128)
declare @newName nvarchar(128)
declare @error_var int, @rowcount_var int
declare @newNameCount int
select @oldName = 'johndoe1'
select @newName = 'johndoe2'
begin transaction
select @newNameCount = count(*)
from Users
where Username = @newName
if @newNameCount > 0
begin
RAISERROR('Username already exists. @newName=%s', 10, 1, @newName)
ROLLBACK TRANSACTION
RETURN
end
update Users
set Username = @newName
where Username = @oldName
SELECT @error_var = @@ERROR, @rowcount_var = @@ROWCOUNT
IF @rowcount_var <> 1 OR @error_var <> 0
BEGIN
RAISERROR('Could not Update User.Username. @oldName=%s', 10, 1, @oldName)
ROLLBACK TRANSACTION
RETURN
END
update aspnet_Users
set
Username = @newName,
LoweredUserName = LOWER(@newName)
where LoweredUserName = LOWER(@oldName)
SELECT @error_var = @@ERROR, @rowcount_var = @@ROWCOUNT
IF @rowcount_var <> 1 OR @error_var <> 0
BEGIN
RAISERROR('Could not Update aspnet_Users.Username. @oldName=%s', 10, 1, @oldName)
ROLLBACK TRANSACTION
RETURN
END
Commit transaction
go
Locopon
Free modules: E-commerce, Complete localization (Portal, page, module settings, skins, etc.), Secure Login, and more
http://dnn.tiendaboliviana.com