Hi,
I have created two stored procedures via VB using this code:
sql = "CREATE PROC " & nombre_proc & " AS SELECT *" & _
" From MBM_PUNTOS_SCE_SIN_COINCIDIR_SIEGE_FALTA_PM_NE_" & mes & _
" WHERE (((IDU) Like 'czz*' Or (IDU) Like 'cam*' Or (IDU) _
Like 'szz*' Or (IDU) Like 'J*' Or (IDU) Like 'G*' Or (IDU) _
Like 'U*'))" & " ORDER BY IDU;"
conexion.Execute sql
sql = "CREATE PROC " & nombre_proc & " AS SELECT *" & _
" From MBM_PUNTOS_SCE_SIN_COINCIDIR_SIEGE_FALTA_PM_NE_" & mes & _
" WHERE (((IDU) Like 'czz*' Or (IDU) Like 'cam*' Or (IDU) _
Like 'szz*' Or (IDU) Like 'J*' Or (IDU) Like 'G*' Or (IDU) _
Like 'U*')=FALSE)" & " ORDER BY 1;"
conexion.Execute sql
If I open the Access database, the first stored procedure returns 123
records and the second returns 2 records, so both procedures seem to
work fine.
I then try to export the records to an Excel sheet via VB:
origen = nombre_proc
conexion.Execute _
"SELECT * INTO [Excel 8.0;DATABASE=" & NombreArchivo & _
"].[" & NombrePestańa & "] FROM " & "[" & origen & "]"
The result is the following:
- When I run the above code for the first stored procedure, the Excel
sheet only contains the captions of the columns, but not the 123
records.
- If I then run the code for the second stored procedure using another
destination sheet in the same workbook, then the second sheet contains
the 123 records that should have appeared in the first sheet and the 2
records that generates the second stored prodedure.
I have tried to execute the exportation sql statements directly from an
access query, and both work as expected, creating two sheets in the
same workbook (the first with 123 data rows and the second with two).
I have no idea about what I could be doing wrong. Anybody has seen this
behaviour before? What could be the reason?
Regards,
Fran