Thanks for posting the dput() output. You can see that the MemberID values are already numbers there. You can tell because there are not quotes around the values. Here is a simple example where I make one numeric column and one character column. In the dput() output, the character variable keeps its leading zero but the numeric one does not.
DF <- data.frame(A = c(123456, 0987654),
B = c("123456", "0987654"))
dput(DF)
structure(list(A = c(123456, 987654), B = c("123456", "0987654"
)), class = "data.frame", row.names = c(NA, -2L))
Somewhere earlier in your code, the MemberID column has been converted to numbers and the leading zeros have been dropped. I expect that the process of writing to Excel is not dropping the zeros; they are not there anymore.
I think the way to solve this problem is to find where the conversion to numbers is happening. Do you know what the column type is in the database? I would expect it to be VARCHAR but it would be good to confirm that. If you run
Data <- sqlQuery(odbcChannel,
"Select distinct
PlanName,
MemberName,
MemberID,
PlanID
From Member
where PlanID ='AR'")
str(Data)
what is the column type of MemberID?