What SQL type is used in Excel - sql

This is my first post in here,
I am new to SQL and I started learning it, I use it mainly in excel to get data from an outer Database
I first go to data then Refresh all then from the menu I choose connection properties
Then a dialogue appears and I input my code in the window called Command text from the Tab Definition
I added images to show where I input my SQL code
My question is what type of SQL do I input there ?
is it mySQL or SQLServer or what ??, so I can learn it, because some commands just don't work with me the way they are supposed to do

You can connect to any database type as long as you have the appropriate ODBC drivers. For example, here is documentation for MySQL for Excel. Quote from article "Use Microsoft Query to retrieve external data":
If the external database that you want to access is not supported by the
ODBC drivers that are installed with Microsoft Query, then you
need to obtain and install a Microsoft Office-compatible ODBC driver
from a third-party vendor, such as the manufacturer of the database.
Contact the database vendor for installation instructions.
OLAP databases do not require ODBC drivers. When you install Microsoft Query, drivers are installed for databases that were created
by using Microsoft SQL Server Analysis Services. To connect to other
OLAP databases, you need to install a data source driver and client
software.
Whichever database type you connect to, you will still be using Microsoft's SQL variant (as developed for SQL Server). As a beginner you're not going to notice too many differences right off the top. Most of the differences are related to data types, such as DATE vs DATETIME. Here is a wiki on SQL Compliance and this article on MS Access SQL will also apply to Excel Query.

You can connect to many data source including: SQL Server database, Access database, MySQL database, PostgreSQL database etc..
You can find the full list here: Link

Related

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.

Data integration between IBM AS400 to SQL Server database

I'm a web developer that has been tasked with creating some sort of mechanism for moving data from an IBM AS400 to a SQL server. Unfortunately, linked servers are out of the question in this case as the SQL Server is just Standard Edition (db2 providers not available in this version) and the AS400 server is on a separate server. I've researched adding some sort of trigger on the AS400 table that calls a web service that would insert data into the SQL server, but that doesn't seem like the best method. Does anyone have any suggestions on the process to get the data from the AS400 to the SQL Server when it is committed to the AS400?
This solution assumes you are familiar with SQL Server Integration Services (SSIS):
Connection to AS400
Create a new ADO.Net connection Manager
Set the Provider to .Net Provider --> ODBC Data Provider
Create a DSN (Control Panel -->Administrative Tools-->Data Sources ODBC -->System DSN)
In the connection manager for Data source specification select the DSN created. Provide the login information.
Test the connection.
Data flow source:
Use the DataReader source
In Advanced Editor select the Ado.Net connection manager just created.
In Component Properties tab --> Custom properties, in SQLCommand specify the required query string (select * from DatabaseName.TableName)
Check the column mappings for accuracy
Go to Input and Output properties -->Data reader output -->External columns (Select the columns which were of type varchar in the table, they will now be of the datatype UnicodeString (DT_WSTR). This is because by default DataReader reads strings as unicode strings. This implies that in the destination table in SQL these columns must be of type unicode i.e NVARCHAR instead of VARCHAR)
Answer sourced from www.sqlservercentral.com/Forums
I synchronize my web applications with an IBM i. But I have my own database design and wrote a sync program on the Windows side.
Having the same database design I wonder why I would need a copy on SQL server. I would access the IBM directly. Install the drivers as #Kamran Farzami suggested and use them. That way there would be no lag between writes on the mainframe and your queries.
If a lag is acceptable for you and you can't access the IBM i directly, I see three main options:
Pull the data from your Windows system with the OLE DB driver. Using the .NET driver you can use the relative record number (RRN) to remember where you stopped synchronizing.
Read the journal files and make them available by creating a webservice on the IBM i.
Read the journal files in a scheduled job and push the changes from the journal to a webservice which updates the SQL server.
Option 1 only works if the files you sync are not reorganized. The RGZPFM command changes the record numbers. If that's okay, you can get the RRN in your SELECT statement: select *, RRN(MYTABLE) as RRNMYTABLE from MYTABLE
The web service server is included in OS400 since V5R4. So you should be able to use option 2.
I've done something similar where the SQL server was in a remote (Honduras) location where the internet connection was unreliable. It was a short VB program, using the OLE DB driver, running on the server that connected to the AS400 when it was available (or "slept" when the connection was down). When available the program would update/synchronize a uniquely keyed mirror file. Another program uploaded individual transaction records to a separate table (file).
We'd also periodically update SQL Server master tables (i.e. item master) from the AS400. That also utilized a VB program (could be any language using the driver) initiated on the server. It isn't exactly elegant, but more practical than an AS/400 trigger to a web service, I believe.

Linking An Access DataBase to Sql Building and building VB InterFace

Hey IO have an old access data base and I have reeated the New data base using SQL Server Management Studio but all the data is still in the Access data base and I was wondering how to link these two. I have been trying to create the linked tables in access using the ODBC tool but none of the table I want are appearing?
Was wondering if anyone has any ideas on how I can do this?
Also I then have started to create the front end of the database using Visual Studio but cant get the fields to populate as the SQL database currently has no data linked to it
Instead of linking tables have you considered using SQL Server Express (you did not mention what the 'new database' is, assume Access?) and the data import wizard to port the data to SQL Server? You get all the tools by downloading 'SQL Server with tools' from Microsoft. And use SSMS for management functions, it is much easier than the Visual Studio interface.

Pervasive PSQL 10 Database to MS SQL Server?

I want to migrate a Btrieve Database to Microsoft SQL Server 2008 R2. I already have done the step of migration to Pervasive PSQL 10 Workstation (x86), which offers an ODBC / OLE DB driver. (It seems Microsof doesn't offer any solution to import Btrieve.)
Ok, so far so good, but how can I transfer the whole database (schema and data) into Microsoft SQL Server? The Import Wizard of SQL Server crashes every time and is useless, because it doesn't map Date- and Memo-Datatypes correctly. I also tried to map these datatypes manually, but the wizard always crashes, caused by ODBC-Errors.
So, I'm looking for a tool which offers a native driver to Btrieve or PSQL 10. It would be nice if it is free, because I only need it for this single migration.
TIA! ^^
There is a tool with a Btrieve driver but you still need the DDFs (just like in ODBC) available from Pervasive called Data Integrator. It is not free but you can find more information at http://integration.pervasive.com/.
Another more manual option would be to export the data from PSQL to CSV, then import the CSV to the MS SQL server. You would have to manually create the tables in the MS SQL database but it could be done with the tools you have.
Also, you say it's crashing with ODBC errors. Are the ODBC errors from PSQL or MS SQL? What are they?

Can SSMA for migrating Access databases to SQL Server 2005 be automated?

I need to migrate Access databases to SQL Server 2005. Since this needs to be done from within a setup so that a customers' installation is transparently migrated to SQL Server 2005, I wonder if it is possible to automate the SSMA toolkit from Microsoft.
Actually SSMA had command-line interface (special console executable in the SSMA installation folder). It was available at some time but I'm not sure whether it made its way to last release. You should ping SSMA support about what versions had it and what examples of its usages are available. I hope this will help you.
To my own knowledge, such an automation is not available. But it is still possible for you to generate the SQL code that creates the database (the one that will begin with the "CREATE DATABASE" sentence) and launch it through your user interface on your SQL server.
To generate this code, you can
Create the access database with the Access toolkit
Generate the corresponing "CREATE DATABASE" SQL code with (for example) SQL Server Management Studio (right-click on database, choose "script database as CREATE". EMS SQL Studio offers a very nice alternative to SQL Server Management Studio
Save the code for further use
With EMS Studio, You can even decide if this code also updates the data. But I'd prefer to automate data transfer through code: you can for example browse the tables (in the right order, depending on relationships), open recordsets (one local, one SQL), and transfer data by browsing the fields (you do not even need to name them) with code like:
(localRecordset links to local table. can be DAO or ADODB; Adjust code accordingly)
(sqlRecordset links to the SQL server. can be DAO or ADODB; Adjust code accordingly)
localRecordset.moveFirst
Do while not localRecordset.EOF
sqlRecordset.addnew
For each field in localrecordset.fields
sqlRecordset.fields(field.name).value = field.value
Next field
sqlRecordset.update
localRecordset.moveNext
Loop