Microsoft Query question. -
06-02-2011
, 01:21 PM
I have a MS SQL database, with multiple tables (over 200) that I am pullinginto a standardized Excel format, for other processing.
The concept is working well but I dread setting this up over 200 times.
The first cell A1 in the spreadsheet (not part of the query, along with thefirst 7 rows) will always have the SQL table name I would want.
I was hoping to find a way that instead of:
"SELECT DXXX1_SQD.ID, DXXX1_SQD.F2, DXXX1_SQD.F3, DXXX1_SQD.F4, DXXX1_SQD.F5, DXXX1_SQD.F6, DXXX1_SQD.F7, DXXX1_SQD.F8, DXXX1_SQD.F9, DXXX1_SQD.F10, DXXX1_SQD.F11, DXXX1_SQD.F12, DXXX1_SQD.F13, DXXX1_SQD.F14, DXXX1_SQD.F15, DXXX1_SQD.F16, DXXX1_SQD.F17, DXXX1_SQD.F18, DXXX1_SQD.F19, DXXX1_SQD.F20, DXXX1_SQD.F21, DXXX1_SQD.F22, DXXX1_SQD.F23, DXXX1_SQD.F24, DXXX1_SQD.F25, DXXX1_SQD.F26, DXXX1_SQD.F27, DXXX1_SQD.F28, DXXX1_SQD.F29, DXXX1_SQD.F30, DXXX1_SQD.F31, DXXX1_SQD.F32, DXXX1_SQD.F33, DXXX1_SQD.F34
FROM OPS.dbo.DXXX1_SQD DXXX1_SQD
ORDER BY DXXX1_SQD.ID"
I could 'pull' from the worksheet in a manner like this:
"SELECT [A1].ID, [A1].F2, [A1].F3, [A1].F4, [A1].F5, [A1].F6, [A1].F7, [A1]..F8, [A1].F9, [A1].F10, [A1].F11, [A1].F12, [A1].F13, [A1].F14, [A1].F15, [A1].F16, [A1].F17, [A1].F18, [A1].F19, [A1].F20, [A1].F21, [A1].F22, [A1].F23, [A1].F24, [A1].F25, [A1].F26, [A1].F27, [A1].F28, [A1].F29, [A1].F30, [A1].F31, [A1].F32, [A1].F33, [A1].F34
FROM OPS.dbo.[A1] [A1]
ORDER BY [A1].ID"
Is there any way to reference the content of a cell, in Microsoft Query?
Or any other suggestions to best deal with this? |