declare @tmpTbl Table(uid int)
declare @userid int
begin
begin TRAN LUOFUXIAN
INSERT INTO @tmpTbl(uid) SELECT userid FROM tbl_news
declare tmpCursor CURSOR
FOR SELECT uid FROM @tmpTbl
OPEN tmpCursor
FETCH NEXT FROM tmpCursor into @userid
while @@FETCH_STATUS=0
BEGIN
UPDATE tbl_users set username='_'+ cast(@userid as nvarchar(255))+'_'
where tbl_users.id=@userid
FETCH NEXT FROM tmpCursor into @userid
END
close tmpcursor
deallocate tmpcursor
if(@@ERROR>0)
BEGIN
ROLLBACK TRAN LUOFUXIAN
END
commit TRAN LUOFUXIAN
end