I am using ODBC to connect to Excel via my DSN which has a default worksheet configured.
I can create pages in the worksheet via the create table command like this:
CREATE TABLE testtable( c VARCHAR(8) )
However when I use the drop table command like this:
DROP TABLE testtable
The Execute function returns a success value but the sheet is not deleted. The column name has been removed but that is all.
Anyone know what might be wrong?
This is a limitation of the Excel ODBC driver - the DROP statement will clear the worksheet, but not delete it.
Related
i have an excel document with conditional formatting and data validation lists and lookups.
The users populate this data in Excel.
I then read it into HANA DB and find any new records required to be enriched.
I would like then to be able to refresh the data in Excel with the data i have in HANA however when I go to import via ODBC I then get a table created.
Ideally, it would paste values back into Excel rather than creating a table object as this removed the formatting included originally
Are there ways around this?
Thank you
Create a hidden sheet where you can place your ODBC source table and write a VBA code that will copy and paste new records from ODBC connection to your user-friendly list. You may filter this enriched records via VBA or PowerQuery join or with something like index and match functions.
I used ODBC to create a sheet in Excel and add a row to it.
Literally the commands were just:
create table 'update5' ('age' NUMBER);
insert into 'update5'.'age' values (1);
This works and I can see the rows in the sheet and via DBVisualiser and my ODBC query results.
Later, I wrote more SQL to add another row like so:
insert into 'update5' ('age') values (2);
but I get the error:
[Microsoft][ODBC Excel Driver] Cannot expand named range.
I do not know why named ranges are being used, is there a way I can set ODBC to not use them?
Without knowing more about what your doing, what you're working with, and your end-goal I can't give a definite answer - however, if you're saying this works fine as-is:
create table 'update5' ('age' NUMBER);
insert into 'update5'.'age' values (1);
...then it stands to reason that this:
insert into update5 values (2);
...will not work because your missing:
quotation marks (which may or may not be optional in your environment), and,
the field name to which you want to export.
In the first insert into statement you have:
'update5' <-- the destination table
.'age' <-- the destination field
values (1); <-- the value to insert
...so if you're just trying to add a record with the number 2 to the same field, use the same code:
insert into 'update5'.'age' values (2);
More Information:
w3schools : SQL INSERT INTO Statement
TutorialsPoint : SQL INSERT Query (Tutorial)
Found it.
When you create an table in Excel via ODBC you create a named range of the same name within that table.
When you try to insert like this:
insert into 'update5'.'age' values (2);
It is interpreted as you trying to add to the the named range called update5 which is inside the table update5.
You need to use the syntax:
insert into [update5$].'age' values (2);
to add values to the table called update5.
I want to load a table data from SQL data bases by Excel ODBC, but the condition "where" i wanted to be dynamic - depended on excel spread cell "A1".
I made somethin like this:
a picture link
select * from tabel where id = ?
But this doesn't work and i donno how to define "?" as A1 Cell
Say you have the following query that works:
If you add a WHERE CLAUSE like so:
Then press OK it should prompt you to refresh your query.
At that point you should get the following dialog, which you can use to set your parameter.
Let's say I have an Access database, "ADB", and an Excel workbook, "EWB".
ADB has a table called "ATable" which contains columns including a column called "A_ID"
EWB has a worksheet called "EWorksheet" which contains columns "E_ID" and "ECol"
Now, I want to know how I can create an Excel worksheet that combines ATable.A_ID from ADB and EWorksheet.ECol from EWB, where if A_ID = E_ID then return ECol.
So in SQL, it should look something like this:
SELECT ATable.A_ID, EWorksheet.ECol
FROM ADB.ATable, EWB.EWorksheet
WHERE ATable.A_ID = EWorksheet.ECol
Of course I want the data to be dynamic, so that data will be updated when refreshed.
You need something called PowerQuery, in Excel 2016 comes by default. In previous versions you will have to install it.
Once you have it, it´s pretty straightforward. Select a connection as seen below selecting an Access database or an Excel workbook.
Once you have both queries loaded in PowerQuery you need to merge them through the column you specified, and that will make the join for you.
What PowerQuery does is record a set of steps such as connecting to an Access database or merging 2 tables. Those steps are saved within the file, so when you click RefreshAll in Excel it will reproduce those same steps you specified and bring you the latest data.
Is there a way to change the data source of a list table in Excel? It's easy to change the data source of a pivot table but the only way I have found to change the data source of a list table is to delete the table and start again.
Just to be clear, what I mean by a list table is what you get when you set up a connection to a table or query in Access (for example) and then click on "Existing Connections" under the Data tab.
I would prefer a method using the usual user interface but if there is a method that works only in VBA, that would be fine.
You can do it from the Excel interface without VBA.
Under the Data tab, click on Connections.
From the Workbook Connections dialog, click Properties.
From the Connection Properties dialog, click Definition.
Browse for a connection file and then select a table.
That's it.
If your data source is inside Excel on another sheet and you're using OLE DB Query, you might find changing the data source impossible (which was the case with me).
To change the data source in this instance, you need to click on Resize Table under the Table Design tab in Excel, as can be seen below:
When you click on this, you are able to change the range of your query, as can be seen below: