Consider a direct connection to workbook with distributed queries using SQL Server's OPENDATASOURCE or OPENROWSET functions:
UPDATE TableName
SET t.adminnumber = s.[adminnumber change]
FROM TableName t
INNER JOIN
OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:\Path\To\Workbook.xls;Extended Properties=Excel 8.0')...Sheet$ s
ON t.adminnumber = s.[adminnumber original]
Alternatively, consider a parameterized query in VBA using ADO where you iteratively bind the old and new numbers in an update query command. Below loops through columns A and B in Sheet 1:
Public Sub UpdateSQL()
Dim conn As Object, cmd As Object
Dim constr As String, strSQL As String
Dim adCmdText As Integer: adCmdText = 1
Dim adInteger As Integer: adInteger = 3
Dim adParamInput As Integer: adParamInput = 1
Dim i As Integer, lastrow As Long
' OPEN DB CONNECTION '
Set conn = CreateObject("ADODB.Connection")
constr = "DRIVER={SQL Server};server=servername;database=databasename;" _
& "UID=username;PWD=password;"
conn.Open constr
strSQL = "UPDATE [TableName] SET [adminnumber] = ?" _
& " WHERE [adminnumber] = ?"
lastrow = Worksheets(1).Cells(Worksheets(1).Rows.Count, "A").End(xlUp).Row
For i = 2 To lastrow
' SETTING COMMAND
Set cmd = CreateObject("ADODB.Command")
With cmd
.ActiveConnection = conn
.CommandText = strSQL
.CommandType = adCmdText
.CommandTimeout = 15
End With
' BINDING PARAMETERS
cmd.Parameters.Append cmd.CreateParameter("newNum", adInteger, adParamInput, 3)
cmd.Parameters(0).Value = Worksheets(1).Range("B" & i)
cmd.Parameters.Append cmd.CreateParameter("oldNum", adInteger, adParamInput, 3)
cmd.Parameters(1).Value = Worksheets(1).Range("A" & i)
'EXECUTE QUERY
cmd.Execute
Next i
conn.Close
End Sub
updatefor each record to the server (2) aggregate all the updates with a table variable (instead of a temp table). Yet, this option is limited to 1,000 updates at a time (3) create an SSIS package and execute it through Excel VBA upon request, (4) export all the updates into aCSV, upload that CSV to a shared location which is available for the SQL server, and then update on the server usingOpenRowSetorBULK INSERT... these are just to name a few of the multiple options you have....Try to be more specific. Otherwise, we can't help.