Hi, Im new in sql especially in stored procedure, I want to convert this code to stored proc i have the idea but not enough anyone please help me. thanks

Public Sub Test(moveFromIndex As Integer, moveToIndex As Integer)
Dim i As Integer

ors.Open "SELECT * FROM database1 WHERE cIndex = '" & moveFromIndex & "'"
db.Execute "DELETE FROM database1 WHERE cIndex = '" & moveFromIndex & "'"
ors2.Open "SELECT * FROM database1"
For i = 1 To ors2.RecordCount
If i = moveToIndex Then
db.Execute "INSERT INTO database1 (cIndex, Name) VALUES ('" & i & "', '" & ors!cName & "')"
Else
db.Execute "INSERT INTO database1 (cIndex, Name) VALUES ('" & i & "', '" & ors2!cName & "')"
End If
Next

End Sub