SQL Dialect Problems

oliver_penney

Board Regular
Joined
Dec 18, 2002
Messages
182
hi all

i have some SQL that i run in a spreadsheet that goes to SQL Server and gets a load of stuff

and :biggrin: it works, hurrah

but i want it to go into Access 2000. so i ODBC all the tables into an .mdb and go to the SQL design of a query, naively paste in the SQL and it doesn't work...

i figure out that you need INNER JOIN instead of JOIN, but i'm having hell with date formats. all i wanna do is pull a date/time field out in the WHERE bit, if SQL server wants me to use CONVERT and Access doesn't know what CONVERT is!

:oops:

any hoo

here is the code that works from the spready

SELECT

si.UnitId,
f.UnitDescription,
Convert(smalldatetime,convert(char(8),si.TransactionDateTime,112)) as Tday,
f.Level2Desc,
f.Level3Desc,
Min(si.TransactionDateTime - Convert(smalldatetime,convert(char(8),si.TransactionDateTime,112))) as Mintime,
Max(si.TransactionDateTime - Convert(smalldatetime,convert(char(8),si.TransactionDateTime,112))) as Maxtime

FROM
SaleItem2 si
JOIN
v_FinancialDimension_For_Cube f
ON si.UnitId = f.UnitId

WHERE
f.Level1Desc= 'Retail - Rail' AND
si.TransactionDateTime >= '20040624' AND
si.TransactionDateTime <= '20040701'

GROUP BY
si.UnitId,
f.UnitDescription,
f.Level2Desc,
f.Level3Desc,
Convert(smalldatetime,convert(char(8),si.TransactionDateTime,112))


any ideas?

thanx in advance

ol
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Why use the SQL?

Why not try using the Query Designer to recreate your query?

Or perhaps you could import the query into Access and it might convert it for you?
 
Upvote 0
Most likely, it's looking at these lines as comparing text to date.

Code:
si.TransactionDateTime >= '20040624' AND 
si.TransactionDateTime <= '20040701'

Try:

Code:
si.TransactionDateTime >= '#20040624#' AND 
si.TransactionDateTime <= '#20040701#'

Mike
 
Upvote 0

Forum statistics

Threads
1,221,783
Messages
6,161,913
Members
451,730
Latest member
BudgetGirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top