How to write LegacySQL in Excel ODBC connection to BigQuery? - sql

I am trying to get data from a LegancySQL View in BigQuery using the Excel ODBC Simba Connection, but it is saying "Cannot reference a legacy SQL view in a standard SQL Query". However, I can't seem to be able to write it as LegacySQL. Adding in #legacySQL at the start of the query gives another error saying that legacySQL is not allowed, however, in their documentation it says it is used by default..?
What can I do?
Thanks,
Benji

Related

Running SQL via SQLWorkbench versus via Tableau Prep

I have developed some SQL that reads from a redshift table, does some manipulation (esp listagg some fields), and then writes to another redshift table.
When I run the SQL using SQLWorkbench it executes successfully. When I embed it in a Tableau Prep flow (as "Complex SQL") I get several of these errors: "System error: AqlProcessor evaluation failed: [Amazon][Support] (40550) Invalid character value for cast specification." Presumably these relate to my treatment of data types. What I don't is what is so difference in the environment that would cause different results like this? Is it because SQLWorkbench and Tableau Prep use different SQL interpreters? Or is my question too broad to even speculate without going through the actual code?
Best guess is that Tableau, which has knowledge of DDL, is add some CAST() operations to the SQL. SQLWorkbench is simpler and is pushing the SQL to Redshift as written. This is based on there being no explicit CASTs in your SQL but an error message that identifies a CAST().
Look at stl_querytext for these two queries and see if they are being given to Redshift differently by the two benches. I suspect this will give you some clues to go on.
If there are no differences in the SQL then the issue may be with user / connection differences and more info will likely be needed about the issue.

Tableau and BigQuery; GROUP_CONCAT not found

I'm using GROUP_CONCAT succesfully in one of my sheets in tableau. It performs as needed and everything works.
When I publish the workbook to tableau however, I get this error:
An unexpected error occurred. If you continue to receive this error
please contact your Tableau Server Administrator.
The Google BigQuery service was unable to compile the query. Function
not found: GROUP_CONCAT at [1:408] 2017-02-06 11:50:35.854,
(WJhi5wrG0e4AACIU#woAAAHo,0,0)
According to this SO post, I should use STRING_AGG instead.
However if I try to use this in tableau, it doesn't recognize it as a valid function.
How could I fix this?
You need to use STRING_AGG in your Tableau -> BigQuery data source, not as a calculated field
BigQuery Standard SQL will then understand the query and the result can be consumed in Tableau

How do I use the SQL IN statement to get MS Access to connect to another MS Access database?

I am trying to use MS Access to query an MS Access database that is not the current database. I am using:
SELECT [tblA].[fieldA]
FROM [tblA]
IN "G:\path\databaseA" "Microsoft.ACE.OLEDB.12.0;"
WHERE ((([tblA].[fieldA])="30000"));
Running this query returns the error Could not find installable ISAM.
I thought the connect string might not be necessary when connecting to another MS Access database (extension .mdb) so I also tried:
SELECT [tblA].[fieldA]
FROM [tblA]
IN "G:\path\databaseA.mdb"
WHERE ((([tblA].[fieldA])="30000"));
However, this returns the error "The text file specification does not exist. You cannot import, export, or link using the specification."
Does anyone know a way around this?

BRIDGE command in Oracle SQL Developer

Occasionally I need to write queries accessing tables in both an MS Access database and an Oracle database. This can be done in MS Access, but Access limits the SQL I can use and has weird syntax.
The BRIDGE command in SQL Developer sounds perfect for this, but I'm having trouble getting it to work. When trying to execute this:
BRIDGE FallEnrollment2012 AS CentralServer(SELECT * FROM "Fall 2012 Enrollment 10-24-12")
SELECT * FROM FallEnrollment2012 WHERE ROWNUM <=10
I get this error message:
ORA-00900: invalid SQL statement
00900. 00000 - "invalid SQL statement"
*Cause:
*Action:
Between BRIDGE and FallEnrollment2012 a syntax error is indicated, but I can't figure out what the issue is. As far as I can tell from the examples I've looked at, it's correct as written. Can anyone tell me what I'm doing wrong?
This is a bug in SQL Developer 4.0 Beta1 & Beta2.
The workaround is to start SQL Developer , Tools > Migration > Scratch Editor .Then open the worksheet and run your BRIDGE command.
In this way the migration plugin is loaded which provides the BRIDGE functionality.
A fix is being worked on
Regards,
Dermot.

SSIS and MySQL - Table Name Delimiter Issue

I am trying to insert rows into a MySQL database from an Access database using SQL Server 2008 SSIS.
TITLE: Microsoft SQL Server Management Studio
------------------------------
ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.51a-community-nt]You have
an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '"orders"' at line 1
The problem is with the delimiters. I am using the 5.1 ODBC driver, and I can connect to MySql and select a table from the ADO.Net destination data source.
The MySql tables all show up delimited with double-quotes in the SSIS package editor:
"shipto addresses"
Removing the double quotes from the "Use a table or view" text box on the ADO.NET Destination Editor or replacing them with something else does not work if there is a space in the table name.
When SSIS puts the Insert query together, it retains the double quotes and adds single quotes.
The error above is shown when I click on "Preview" in the editor, and a similar error is thrown when I run the package (albeit then from the actual insert statement).
I don't seem to have control over this behavior. Any suggestions? Other package types where I can hand-code the SQL don't have this problem.
Sorry InnerJoin, I had to take the accepted answer away from you. I found a workaround here:
The solution is to reuse the connection for all tasks, and to turn ANSI quotes on for the connection before you do any inserts, with an Execute Sql task that runs the following:
set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,
NO_ENGINE_SUBSTITUTION,ANSI_QUOTES'
Try using square brackets around the table names. That may help.
EDIT: If you can, I would create views (with no spaces) based on the Access tables, and use those to export. Even if it means building another Access database with linked tables, I think this is your best bet.
I've always struggled with using SSIS with MYSQL directly. Even after installing the ODBC drivers, they just don't play well in data flows. I've always ended up creating linked ODBC connections between SQL Server and MYSQL. I then rely on linked server queries to bring over data. Instead of using a SSIS data flow task, I use an Execute SQL command, usually in the form of a stored procedure that executes an OPENQUERY.
One solution you could do is load the data into a SQL Server database and use it as a staging environment before you load it into the MYSQL database. I regularly move data between SQL Server 2008 and MYSQL and in the past I use to regularly move data between Access and SQL Server.
Another possible solution is to transform the incoming Access data before it loads into the MYSQL database. That may give you a chance to clean up the column names and the actual data that's going through to MYSQL.
Let me know if either of these work for you.
You can locate the configuration setting file my.ini at <<Drive>>:\ProgramData\MySQL\MySQL Server 5.6\my.ini and add "ANSI_QUOTES" to sql-mode.
e.g: sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES". This should solve the issue while previewing in the SSIS editor.