J
Jimbo
Greetings,
I’m having a problem getting MS Query to return the results of a query to
Excel. To illustrate the point I built two queries that have identical
results in MS Query where one works as expected when I select “Return Data to
Microsoft Office Excel†in the file menu yet one stubbornly refuses to
populate the spreadsheet. SQL for each (this seems to be the only
difference) is,
Working Query:
DECLARE @DATE1 datetime
DECLARE @DATE2 datetime
Set @Date1='01/01/2009'
Set @Date2='12/31/2009'
SELECT
NOTES_GCAR.CARNumber,
NOTES_GCAR.CARState,
NOTES_GCAR.CARRegion,
NOTES_GCAR.CARSubRegion,
NOTES_GCAR.CAROpenDate,
NOTES_GCAR.CARCloseDate,
NOTES_GCAR.CARHistory,
NOTES_GCAR.CARAdministrator
FROM DMBI.dbo.NOTES_GCAR NOTES_GCAR
WHERE
NOTES_GCAR.CARCloseDate Between @Date1 And @Date2
AND CHARINDEX('Tony Roma',NOTES_GCAR.CARAdministrator) > 0
ORDER BY NOTES_GCAR.CARCloseDate
Failed Query:
DECLARE @DATE1 datetime
DECLARE @DATE2 datetime
DECLARE @ADMIN1 varchar(30)
Set @Date1=’01/01/2009’
Set @Date2=’12/31/2009’
Set @Admin1=’Tony Roma’
SELECT
NOTES_GCAR.CARNumber,
NOTES_GCAR.CARState,
NOTES_GCAR.CARRegion,
NOTES_GCAR.CARSubRegion,
NOTES_GCAR.CAROpenDate,
NOTES_GCAR.CARCloseDate,
NOTES_GCAR.CARHistory,
NOTES_GCAR.CARAdministrator
FROM DMBI.dbo.NOTES_GCAR NOTES_GCAR
WHERE
NOTES_GCAR.CARCloseDate Between @Date1 And @Date2
AND CHARINDEX(@Admin1,NOTES_GCAR.CARAdministrator) > 0
ORDER BY NOTES_GCAR.CARCloseDate
In addition, I can’t convert either of these to a parameter query to capture
the set criteria because the query can’t be displayed graphically.
I’m having a problem getting MS Query to return the results of a query to
Excel. To illustrate the point I built two queries that have identical
results in MS Query where one works as expected when I select “Return Data to
Microsoft Office Excel†in the file menu yet one stubbornly refuses to
populate the spreadsheet. SQL for each (this seems to be the only
difference) is,
Working Query:
DECLARE @DATE1 datetime
DECLARE @DATE2 datetime
Set @Date1='01/01/2009'
Set @Date2='12/31/2009'
SELECT
NOTES_GCAR.CARNumber,
NOTES_GCAR.CARState,
NOTES_GCAR.CARRegion,
NOTES_GCAR.CARSubRegion,
NOTES_GCAR.CAROpenDate,
NOTES_GCAR.CARCloseDate,
NOTES_GCAR.CARHistory,
NOTES_GCAR.CARAdministrator
FROM DMBI.dbo.NOTES_GCAR NOTES_GCAR
WHERE
NOTES_GCAR.CARCloseDate Between @Date1 And @Date2
AND CHARINDEX('Tony Roma',NOTES_GCAR.CARAdministrator) > 0
ORDER BY NOTES_GCAR.CARCloseDate
Failed Query:
DECLARE @DATE1 datetime
DECLARE @DATE2 datetime
DECLARE @ADMIN1 varchar(30)
Set @Date1=’01/01/2009’
Set @Date2=’12/31/2009’
Set @Admin1=’Tony Roma’
SELECT
NOTES_GCAR.CARNumber,
NOTES_GCAR.CARState,
NOTES_GCAR.CARRegion,
NOTES_GCAR.CARSubRegion,
NOTES_GCAR.CAROpenDate,
NOTES_GCAR.CARCloseDate,
NOTES_GCAR.CARHistory,
NOTES_GCAR.CARAdministrator
FROM DMBI.dbo.NOTES_GCAR NOTES_GCAR
WHERE
NOTES_GCAR.CARCloseDate Between @Date1 And @Date2
AND CHARINDEX(@Admin1,NOTES_GCAR.CARAdministrator) > 0
ORDER BY NOTES_GCAR.CARCloseDate
In addition, I can’t convert either of these to a parameter query to capture
the set criteria because the query can’t be displayed graphically.