Ok first the query I will be displaying is very rough looking. Pointers on how to optimize it would be great but that is not my main purpose right now I need something that works. I will post the query and the results
SELECT u.[UserName]
,u.[LoweredUserName]
,m.[BarCode]
,m.[MemberID]
,d.[FirstName]
,d.[LastName]
FROM [sqlmdstgbiz02].[WebDB].[dbo].[aspnet_Users] u,
[mdsqlst].[CMS_PRODUCTION].[dbo].[memMember] me,
[mdsqlst].[CMS_PRODUCTION].[dbo].[Demographics] d,
[sqlmd05stg\sqlmd05stg].EntranceControl.dbo.MemberBarCodes m
where
(substring(u.UserName, len(u.UserName)-12,13) = m.Barcode or
substring(u.UserName, len(u.UserName)-11,12) = m.Barcode or
substring(u.UserName, len(u.UserName)-10,11) = m.Barcode or
substring(u.UserName, len(u.UserName)-9,10) = m.Barcode or
substring(u.UserName, len(u.UserName)-8,9) = m.Barcode) and
me.MemberID = m.MemberID and me.DemographicsID = d.DemographicsID
The results of the code are
UserName BarCode MemberID FirstName LastName
down120000008 120000008 8300100364005 TOUCH DOWN
test120000009 120000009 8300100606009 KET TAG TEST
abbott123567567 123567567 8300100635008 HENRY ABBOTT
Now as you can see the UserName is simple the Lastname and the BarCode combined together. What I need to do is update the UserName with the LastName and MemberID but in a way that will allow me to update hundreds of UserName with one script. All of this information is on different servers so I know I have to do a Linked Server which the DBA is setting up right now. Any more information please ask.
Assuming this is SQL Server, you can use UPDATE FROM to perform the update.
Edit
As HLGEM correctly points out, you should replace the implicit syntax with proper INNER JOIN statements.