Issuing Teradata SQL Assistant query via script - sql

I use Teradata SQL Assistant to run SQL queries against a DB2 database accessed via an ODBC connection. This is an entirely interactive process whereby I first start the SQL Assistant app, then connect to the correct data source and finally write and execute my query.
What I would like to do is to be able to achieve the same result, i.e. get the result set from a query, but via some sort of script, which would connect to the the data source and run my query.
Is this possible?

Yes this is possible. Install the IBM Data Server Client software appropriate for your version of DB2, then use the DB2 command line processor with the -f option, as described in the manual.

Related

QODBC Online linked server to SQL server has empty tables - no data

I have a linked server from SSMS to Quickbooks through QODBC Online. I have run the QODBC Setup Screen and connected to the desired client. The query runs but returns no data. it shows all the column names but no data. am I missing a step?
created linked server. tested connection. run query. no results
Im able to connect and receive data through powerbi but nothing on sql server.
what am i missing?
Please check if you are able to query the table using QODBC Online Test Tool.
If you are using SQL Server 32-Bit, use the 32-Bit test tool. If you are using SQL Server 64-Bit, use the 64-Bit test tool.
If you cannot get the results in the test tool, please reset the QODBC Online Optimizer.
QODBC Online Setup Screen >> Optimizer >> Reset Optimizer.
If you can get the results in the test tool, the same SQL statement should also work in the SQL statement.
If you are still facing the issue, please raise a support ticket at https://support.qodbc.com

Excel OBDC - SQL Query

I am trying to use Excel pull data from a large Oracle Data Warehouse via an ODBC connection. I have a query that works using the editor in Access. I've tried using Power Query and Microsoft SQL to use this query to get this data into Excel and I get errors.
Therefore:
Does SQL executed from Excel need to be in a different syntax? Shouldn't it still be Oracle?
How can I use this pre-written query to ping the data warehouse and get what I need?
Here is the SQL that I have so far. I had to change some table names...sorry if that makes it weird.
The SQL you posted uses Access-specific functions. That is NOT a valid SQL query if run directly against Oracle. If you have a bunch of linked tables in Access, that would allow this.
The ODBC datasource connection in Excel works differently. ODBC executes the query directly at the datasource. It does some validation first and supports a limited subset of SQL language supported at the destination. What's included in the subset is determined in part by the driver selected for the connection.
So what you want to do is use a tool that lets you build the query directly in an Oracle environment, like Quest Toad or Oracle SQL Developer. Once you have the query working there, it should be easier to port it to Excel.
One thing I like to do is put my query into a view on the database. Then I can just select everything from the view when creating the Excel connection.
It's also worth pointing you to the My Data Sources folder. When you first setup an ODBC connection in Excel, the connection is saved by default in Windows in a folder called "My Data Sources" located just under your user profile folder. For example: C:\Users\UserName\My Data Sources\Data Source Name.odc.
You can open these *.odc files in any text editor, and you should be able to manually edit the SQL here. Especially look for the <odc:CommandText> element. In this way you can build a simple query up front, and then improve on the SQL command in your favorite environment and easily move the updated SQL to the existing ODBC connection.

How to Execute SQL Server query (procedure) from another PC in network

Situation now
We have a netrowk set up. Some PCs have SQL Server 2012 installed, some don`t.
Is it possible to write a stored procedure and have it invoked/executed by another user/PC without SQL Server? For example by some .bat/.cmd script, I don`t know.
Desired situation
I write SQL query on my SQL Server management studio.
I save the query as a stored procedure. <-- up to here I am OK.
I do something that makes the procedure availible to other users. The advice I get from this question (I hope).
Other colleagues execute the procedure.
They get a result of the query in a CSV.
The client computers that need to run the stored procedure could install the sqlcmd utility. This allows for the execution of sql commands on another SQL Server.
SQLCmd -S<<SERVERNAME\INSTANCENAME>> -Q "Execute dbo.YourStoredProcedure"
And then have your stored procedure save the CSV file to a network drive or send it via e-mail.
Another way to retrieve data could be using the BCP utility. In this way the user could connect to your server, execute the query and receive a CSV file to a specified location on their computer.
In both cases it involves installing an additional program on the client computer.
You don't need SQL Server installed in the client machines to run queries or execute procedures. At most, depending on which programming language you are are using, you need the client installation for SQL Server. This is true for any DBMS, even Microsoft SQL Server 2014.
If you implement you code in Java, for example, you don't need even the MS SQL Server client. The JDBC driver for MS SQL Server is enough. It can be download from Microsoft and is not part of the SQL Server client installation.

how to access DB from command prompt to write SQL queries?

how to connect to DB from command prompt in windows 7 for the purpose of writing SQL queries and how to access all SQL tables and files?
You can use Oracle SQL*Plus
Which is an interactive and batch command-line query tool that is installed with Oracle Database Express Edition.
For MSSQL you may use the sqlcmd Utility.
For connect to SQL you can use osql.exe tool, which allow you to connect to database, write queries, and even administering.

Get SQL statement after parameters added

Is there a way (in MySQL) to get the pure SQL statement after parameters have been added? I'm having issues with one of my statements once I start using parameters, and I want to see what's being executed. Of course it has to do with dates.
Using MySQL .NET Connector. I have access to MySQL server, and I use SQLYog to administrate.
Thanks!
-Steve
You can use the query logs option to have all queries issued to the server logged.
See http://dev.mysql.com/doc/refman/5.1/en/server-logs.html for information about the log types and how to enable and configure them.