Glenn Stearns
asked on
SQL Data Connection from Excel 2007
I am now connecting to SQL tables from inside Excel using Data -> External Connections. Previously, those SQL tables were FoxPro tables. The SQL connection text which worked with the VFP tables (using the VFP format for external connections) does not work with SQL tables directly.
This is one of the former connection texts which worked with VFP:
SELECT (alltrim(intran.fpartno)+" / "+alltrim(intran.fcpartrev )), Sum(intran.fqty*(-1))
FROM intran intran
WHERE (intran.type = 'I') AND (intran.fdate>={d '2005-12-31'})
GROUP BY intran.fpartno,intran.fcpa rtrev
What I need to do now is connect from inside Excel to the external SQL table and execute SQL commands that will do what the ones above did when connected to the VFP table. I am using MS SQL Server 2005. The intran table has over 500,000 records in it. The only Excel-to-dbf utility I have will not work with Excel 2007 (xlsx) files--longer than 65K rows. What SQL commands do I enter in the command text tab to accomplish this when connected to a SQL table?
Glenn
This is one of the former connection texts which worked with VFP:
SELECT (alltrim(intran.fpartno)+"
FROM intran intran
WHERE (intran.type = 'I') AND (intran.fdate>={d '2005-12-31'})
GROUP BY intran.fpartno,intran.fcpa
What I need to do now is connect from inside Excel to the external SQL table and execute SQL commands that will do what the ones above did when connected to the VFP table. I am using MS SQL Server 2005. The intran table has over 500,000 records in it. The only Excel-to-dbf utility I have will not work with Excel 2007 (xlsx) files--longer than 65K rows. What SQL commands do I enter in the command text tab to accomplish this when connected to a SQL table?
Glenn
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT (ltrim(rtrim("m2mdata03"." dbo"."intr an"."fpart no"))+" / "+
rtrim(ltrim("m2mdata03"."d bo"."intra n"."fcpart rev"))), Sum(intran.fqty*(-1))
FROM "m2mdata03"."dbo"."intran"
WHERE ("m2mdata03"."dbo"."intran "."type" = 'I') AND ("m2mdata03"."dbo"."intran "."fdate"> = '2005-12-31')
GROUP BY "m2mdata03"."dbo"."intran" ."fpartno" ,"m2mdata0 3"."dbo"." intran"."f cpartrev"
Are you using the Query builder, the GUI tool?
rtrim(ltrim("m2mdata03"."d
FROM "m2mdata03"."dbo"."intran"
WHERE ("m2mdata03"."dbo"."intran
GROUP BY "m2mdata03"."dbo"."intran"
Are you using the Query builder, the GUI tool?
ASKER
I have the Query Builder tool that's part of SQL Server 2005. I also have SQL Manager for SQL Server, a 3rd party tool that has a good query builder in it.
I'm still getting the same "Table does not exist." message. Evidently that Command Text box does not want SQL statements like it puts there when the table being connected to is a VFP table. I suppose I should try building the SQL query using the Query Builder tool and save the resulting SQL table as the one I connect to from Excel. I'm not real sure what to try next!
I'm still getting the same "Table does not exist." message. Evidently that Command Text box does not want SQL statements like it puts there when the table being connected to is a VFP table. I suppose I should try building the SQL query using the Query Builder tool and save the resulting SQL table as the one I connect to from Excel. I'm not real sure what to try next!
ASKER
This is the default Connection String showing in the Connection Properties/Definition Tab (after I've selected SQL as the connection and selected m2mdata03 as the database and intran as the table from the list of of choices in the drop-down selection box):
Provider=SQLOLEDB.1;Integr
This is the default Command Text showing in the Connection Properties/Definition Tab (double-quotes are part of the text):
"m2mdata03"."dbo"."intran"
If I accept this default text, Excel will import the entire intran table just fine (unmodified by the trim statements, of course, which isn't the way I want the data import to Excel to work!). If I replace the Command Text with your command text, Excel tells me "Table does not exist."
From a purely SQL standpoint, your command statements look correct; they just don't work in the Excel 2007 data connections process. What would you suggest I try in consideration of this?
Thanks!