The way to connect to SQL Server using unix bash scripts - sql-server

I have seen a lot of links on the internet regarding this but I am in a little fix as to how can we connect to a SQL Server database and insert some records to it using a shell script.
I want to be able to create a function which accepts the values for the row, creates an sql statement and then executes it to insert data into the SQL Server Database. I know that there is Microsoft ODBC for this but I am not sure as to how we can create the said function with it.

Related

How to create Linked Server in Sybase IQ DB to connect to MS SQL Server

We are trying to load data in a table in Sybase IQ from MS SQL Server. We are trying to load it by writing a stored procedure which does insert into ....
Currently, it is unsuccessful as the stored procedure is not able to find the source table directly.
Is it possible to create linked server kind of thing in Sybase IQ to connect to MS SQL source database so that it behaves like a local table?
You can use ECDA (used to be called Direct Connect) - there's an explanation of how to set it up here using ECDA on a separate Windows host (easier because then you can use a standard ODBC driver to connect to MSSQL).
https://blogs.sap.com/2015/11/18/connect-sybase-iq-16-on-aix-with-remote-server-to-mssql-with-ecda-without-odbc-configuration/

Problem connecting AS400 (V7R3M0) with SQL Server 2017 via ODBC Link Server

I have a problem connecting AS400 (V7R3M0) with SQL Server 2017 via ODBC Link Server. It is very slow.
SELECT *
FROM AS400.CATALOG.LIBDTA.TABLE1
WHERE ...
How to fix this? If you don't want to use OPENQUERY
Thanks
How to fix this? If you don't want to use OPENQUERY
You can't...MS in their infinite wisdom decided that the way a (non-MS?) linked server would work is that the entire table would be pulled back and the where performed locally.
If you use OPENQUERY, then the SQL is sent to the linked server, executed and only the results are returned.
I supposed if your WHERE clause is static, you could set up a view on the IBM i side, then just query the view. But those use cases are few and far between.

SQL Server Backend, Access front end connection question

I transferred my Access Back-end to SQL Server and linked the tables. I used the SQL Server Migration Wizard. When I ran my Forms, Reports and Queries, I was surprised to see that it worked perfectly fine as if I did not even migrate.
How is it the JET SQL syntax of Access able to retrieve data from SQL Server which uses T-SQL language?
Because Jet doesn't need to use Transact-SQL, it just knows how the data is stored, the same way you can use an ODBC connection to pull data from an Oracle database without using PL-SQL. Also, you can write a stored procedure in the SQL database, using T-SQL, and you can fire it off via Jet: the proc lives and runs on the SQL side, and Jet doesn't need to know how it works, just how to fire it.

Create database for SQL Server

At work, I'm able to connect to several SQL Server databases which I can write code to query from. I would like to be able to have my own database on my own computer at home so that I can practice writing queries.
So according to https://msdn.microsoft.com/en-us/library/ms186312.aspx, the steps that I should follow is:
Using SQL Server Management Studio
To create a database
In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.
Right-click Databases, and then click New Database.
So I'm kind of stuck on step one because I don't have any database / servers/ instances (I may be using the wrong terminology here). How do I get one? I would really appreciate it if someone can give me a high leveled overview of how everything is related.
1) Instal SQL server to your local PC, some help you can find here https://learn.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-from-the-installation-wizard-setup
2) Connect to your SQL server
3) Clicl "New Query" and exec
create database test
This stmt will create DB with name "test" and default properties

Azure Linked Server:

I understand that there are a few threads existing on this area, around a local server using Azure MSSQL as a linked DB.
My specific issue is the linked server appears, connects and I can view the databases but when trying to go deeper, as in see the tables I get the following error:
Reference to the database and/or server name in
'databasetable.sys.sp_tables_rowset2' is not supported in this version
of SQL Server. (Microsoft SQL Error, Error 40515).
I have tried any of the suggestions already mentioned via the other threads, and to no avail can I get any deeper than listing the databases on the Azure server from my local installation of SQL Server.
I experience the same issue when trying to do anything more than simple Select/Insert/update/delete/create Table/Drop table on my SQL Azure databases. It appears you cant do anything that touches the settings of SQL Server or any stored procs that touch system tables, perhaps because the SQL servers could be shared between multiple customers.
There are also documented areas where Azure SQL has limitations versus a local SQL Server.
We now have this capability using elastic database query, you need to follow two simple steps mentioned as:
Step-1: Create reference to external database
Step-2: Then create remote table reference in the target database
then you can execute remote queries just the way you do it with SQL Server.
Please refer for step by step details https://azure.microsoft.com/en-us/documentation/articles/sql-database-elastic-query-getting-started-vertical/

Resources