I fetch data from SQL Sever 2005 through MS Access interface using SQL Pass-Through Queries (SPTQ). I have two queries with the same sql text inside (please see the code snippet) and connect to the same database, same tables; only the filter (A.CY_CYCLE Like %D-DC8-P%) is different.
When I fetch the data with filter A.CY_CYCLE Like %D-DC8-P% (newly available data in the table) MS Access does not throw any error message and all data is fetched successfully.
However when I fetch data with filter A.CY_CYCLE Like %D-DC5-P% (old data available in the table) MS Access throws error "ODBC--call failed. [Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.(#242)"
On the SQL server TC_EXEC_DATE field is defined as datetime whereas B.TC_EXEC_TIME field is defined as VARCHAR(15).
I want to combine these two fields and get one datetime field.
Why the same sql text works fine where as it does not work for the other???
Any answers will be much appreciated.
SELECT A.CY_CYCLE_ID AS [TESTSET_ID], A.CY_CYCLE AS [TESTSET_NAME], A.CY_OPEN_DATE AS [TESTSET_CREATION_DT], B.TC_TEST_ID AS [TESTCASE_ID], C.TS_NAME AS [TESTCASE_NAME], C.TS_STEPS AS [TEST_STEPS], B.TC_STATUS AS [TC_STATUS], cast((CONVERT(VARCHAR(10), B.TC_EXEC_DATE, 101)) + ' ' + (CONVERT(CHAR(8), B.TC_EXEC_TIME, 108)) as datetime) AS [TC_EXEC_DT], case when ISNULL(B.TC_ACTUAL_TESTER,'')='' then B.TC_TESTER_NAME else B.TC_ACTUAL_TESTER end AS [ASSOCIATE_ID], LEFT(A.CY_CYCLE,CHARINDEX('-',A.CY_CYCLE)-1) AS MNEMONIC
FROM TD.CYCLE AS A, TD.TESTCYCL AS B, TD.TEST AS C WHERE a.CY_CYCLE_ID = b.TC_CYCLE_ID AND C.TS_TEST_ID=B.TC_TEST_ID AND A.CY_CYCLE Like '%D-DC5-P%'