从SQL中提取时跳过excel中的列

从SQL中提取时跳过excel中的列,sql,excel,vba,Sql,Excel,Vba,因此,当我运行select语句时,我想跳过excel中的一列: strSql=strSql&“COLCUDF.Revision#1Date” 及 strSql=strSql&“COLCUDF.FinalActDate” 因为那列有公式 Dim rstProjRls As New ADODB.Recordset Dim cmdProjRls As New ADODB.Command Set cnnSSVERP = New ADODB.Connection cnnSSVERP.Open "Driv

因此,当我运行select语句时,我想跳过excel中的一列:

strSql=strSql&“COLCUDF.Revision#1Date” 及 strSql=strSql&“COLCUDF.FinalActDate”

因为那列有公式

Dim rstProjRls As New ADODB.Recordset
Dim cmdProjRls As New ADODB.Command

Set cnnSSVERP = New ADODB.Connection
cnnSSVERP.Open "Driver={SQL Server};Server=" & Range("dbServer") & ";Database=" & Range("dbName") & ";Uid=" & Range("dbUser") & ";Pwd=" & Range("dbPassword") & ";"
cnnSSVERP.CursorLocation = adUseClient

If cnnSSVERP.State Then
Else
    GoTo No_Connection
End If

strSql = ""
strSql = strSql & "Select "
strSql = strSql & " Coalesce(Year(PRI.ShipSchedDate), Year(PRI.PMReq),0) As ReportYearGroup, "
strSql = strSql & " Coalesce(Month(PRI.ShipSchedDate), Month(PRI.PMReq),0) As ReportMonthGroup, "
strSql = strSql & " CO.ID As SalesOrder, "
strSql = strSql & " COLCUDF.ReleaseNo, "
strSql = strSql & " PRI.ProjectName, "
strSql = strSql & " LTrim(COL.MISC_REFERENCE) As Description, "
strSql = strSql & " COCUDF.ProjectType, "
strSql = strSql & " PRI.Plant, "
strSql = strSql & " PRI.ReleaseStatus, "
strSql = strSql & " COLCUDF.EngineerLead, "
strSql = strSql & " COLCUDF.Engineer, "
strSql = strSql & " COCUDF.Estimator, "
strSql = strSql & " PRI.ProjectManager, "
strSql = strSql & " COLCUDF.PostCheck, "
strSql = strSql & " COLCUDF.ProjTODate, "
strSql = strSql & " COLCUDF.CalcNumber, "
strSql = strSql & " COLCUDF.StampDueDate, "
strSql = strSql & " COLCUDF.StampActDate, "
strSql = strSql & " COLCUDF.SubDueDate, "
strSql = strSql & " COLCUDF.SubOutDate, "
strSql = strSql & " COLCUDF.RevisionNumber, "
strSql = strSql & " COLCUDF.InRevision#1Date, "
strSql = strSql & " COLCUDF.Revision#1DueDate, "
strSql = strSql & " COLCUDF.Revision#1Date, "

strSql = strSql & " COLCUDF.FinalActDate, "
strSql = strSql & " PRI.Installation, "
strSql = strSql & " COLCUDF.TCODate, "
strSql = strSql & " COLCUDF.Notes "

这将插入一个空列:

strSql = strSql & " COLCUDF.Revision#1Date, " 
and strSql = strSql & "'', "
and strSql = strSql & " COLCUDF.FinalActDate, " 
我希望这有帮助! 马克斯