SQL Server 2016 and creating External Tables - sql-server

I have a database in SQL Server 2016. I have a linked server to an SAP HANA database as well. What I am trying to do is add a table from the HANA database to my database as an external data table. Is this possible?
I am not sure about the best way to do it. I have tried the create external table, but I keep getting the syntax error near 'External.'
Basically have a table in the SQL Server database that is linked to the SAP HANA table, so that I can treat the table as any other table. I know I can use openquery to create stored procedures, but I am wondering if I can create it as a linked table in my database.

No, It is not possible.
Creating an external table is for PolyBase to access data stored in a Hadoop cluster or Azure blob storage PolyBase external table that references data stored in a Hadoop cluster or Azure blob storage.
But SAP HANA is another RDBMS.

Related

Data Migration from On Prem to Azure SQL (PaaS)

We have an on-prem SQL Server DB (SQL Server 2017 Comp 140) that is about 1.2 TB. We need to do a repeatable migration of just the data to an on cloud SQL (Paas). The on-prem has procedures and functions that do cross DB queries which eliminates the Data Migration Assistant. Many of the tables that we need to migrate are system versioned tables (just to make this more fun). Ideally we would like to move the data into a different schema of a different DB so we can avoid the use of External tables (worried about performance).
Moving the data is just the first step as we also need to do an ETL job on the data to massage it into the new table structure.
We are looking at using ADF but it has trouble with versioned tables unless we turn them off first.
What are other options that we can look and try to be able to do this quickly and repeatedly? Do we need to change to IaaS or use a third party tool? Did we miss options in ADF to handle this?
If I summarize your requirements, you are not just migrating a database to cloud but a complete architecture of your SQL Server, which includes:
1.2 TB of data,
Continuous data migration afterwards,
Procedures and functions for cross DB queries,
Versioned tables
Point 1, 3, and 4 can be done easily by creating and exporting .bacpac file using SQL Server Management Studio (SSMS) from on premises to Azure Blob storage and then importing that file in Azure SQL Database. The .bacpac file that we create in SSMS allows us to include all version tables which we can import at destination database.
Follow this third-party tutorial by sqlshack to migrate data to Azure SQL Database.
The stored procedures can also be moved using SQL Scripts. Follow the below steps:
Go the server in Management Studio
Select the database, right click on it Go to Task.
Select Generate Scripts option under Task
Once its started select the desired stored procedures you want to copy
and create a file of them and then run script from that file to the Azure SQL DB which you can login in SSMS.
The repeatable migration of data is challenging part. You can try it with Change Data Capture (CDC) but I'm not sure that is what exactly your requirement. You can enable the CDC on database level using below command:
Use <databasename>;
EXEC sys.sp_cdc_enable_db;
Refer to know more - https://www.qlik.com/us/change-data-capture/cdc-change-data-capture#:~:text=Change%20data%20capture%20(CDC)%20refers,a%20downstream%20process%20or%20system.

How to Migrate data from multiple T-SQL Queries to Single Table?

I want to enter data from mutiple T-SQL queries into my azure sql database, We want to enter data in such a way so that we have 8 columns in a single table in azure sql database, and for those 8 columns we have multiple T-SQL statements that 1 for each that will enter the data from the select statments into the azure sql database, how can this be achieved, for long term we want this to run as a job going forward.
If your multiple T-SQL queries run in one database, I suggest you can think about the Azure Data Factory.
Azure Data Factory can help migrate data from one table or multiple tables to Azure SQL database by T-SQL queries.
You also can trigger the pipeline runs on a schedule. You can create a scheduler trigger to schedule the pipeline to run periodically (hourly, daily, and so on).
For details about Data factory, please see Azure Data Factory Documentation.
Tutorials:
Incrementally load data from multiple tables in SQL Server to an Azure SQL database
Copy multiple tables in bulk by using Azure Data Factory.
And if your source data is in SQL Server instance, you can create a linked server to Azure SQL Database, this also can help you achieve that.
You can query and insert data to linked Azure SQL server by T-SQL statements.
About SQL Server linked server, please see: Create Linked Servers (SQL Server Database Engine)
Hope this helps.

How to convert database in SQL Server to schema based object in Azure SQL

I'm trying the migrate a database to Azure SQL. As I'm trying to minimize the servers, the challenge is like let's say db name is college, under college db we have table folder and I have a table name "forms". In order to access forms, it will be like college..dbo.forms.
Now I'm trying to migrate the database and tables in Azure SQL. I want the database to be converted into schema based object. Let's say for accessing table "forms" under college, it will be like "college.forms". There will be no separate database "college".
As I know, you could not do that during migrating.
No matter which way you migrate your database to Azure SQL, you all need to do the two steps:
specify the source server and database.
select schema objects.
[dbo] is the default schema in Azure SQL. And a new database will certainly appear in Azure SQL.
Reference: SQL Server database migration to Azure SQL Database.
But Azure SQL database supports your create or alter the default schema.
You can see:
CREATE SCHEMA (Transact-SQL);
ALTER SCHEMA (Transact-SQL);
DROP SCHEMA (Transact-SQL).
Hope this helps.

Unable to migrate data from sql server to aurora Mysql DB using AWS data migration service

I am unable migrating data from SQL server to aurora MySQL DB using AWS DMS service. Currently, I have a different number of columns for a particular table in MySQL DB due to which I am unable to transfer data from SQL server to aurora MySQL DB.
Please check the below image for reference.
As the picture suggests, I want to transfer data from booking table in SQL server to booking table in aurora Mysql DB having less number of columns.
Can anyone suggest a way to do it?
There may be a way to cope with this directly from AWS without having to change your schema. But, one option here would be to simply create a table in MySQL which matches the column/type count of the counterpart in SQL Server, i.e.
CREATE TABLE booking (bookingID int, bookingVersion int, ...) -- 7 columns
Then, migrate the data from SQL Server to MySQL using the AWS tool. Finally, just drop the bookingVersion column from your MySQL table:
ALTER TABLE booking DROP COLUMN bookingVersion;
This should work, because all the extra DML steps I suggested can completely be done within MySQL, and don't involve your SQL Server database at all.

Automatically update SQL Server database from tables in MS Access

I'm new to SQL Server and trying to automatically update tables in SQL Server from tables in MS Access.
I have an Access database of metadata that must be kept updated for sending records to other groups. I also have a database in SQL Server which also has these same metadata tables. Currently these tables in the SQL Server database get updated manually by exporting the Access tables as Excel files, and then importing them into the SQL Server tables.
It's not the most efficient process and could lead to errors in the SQL Server database if someone forgets to check that they are using the most recent data from Access. So I would like to integrate some of the tables from Access to my database in SQL Server. Ideally I would like for the tables in my SQL Server database to be updated whenever Access is updated or at least update the tables automatically in the SQL Server database when I open it.
Would replicating the Access tables be the best? I am using SQL Server 2014 Developer so I think I have this capability. From my understanding, mirroring is for an entire database not just pieces of it. However, I do not want to be able to alter the metadata from SQL Server and have it reflected in Access. I cannot tell if reflecting the tables would do this...?
I also looked at this post about writing multiple insert statements but was confused (What is the best way to auto-generate INSERT statements for a SQL Server table?). Someone else suggested importing all the data into SQL Server and then using an ODBC driver to connect the two, but I'm also not sure how this would update the database in SQL Server anytime Access is updated.
If you have any suggestion and a link to easy to follow tutorial I would really appreciate it!
Thanks
In Access, go to 'External Data', ODBC Database, and connect to the SQL Server database directly - make sure you select 'Link to the data source by creating a linked table' on the first page of the wizard. Now, this linked table is available in Access, but is actually the SQL Server table.
Get rid of the local Access tables, using the new linked tables in their place in whatever queries, forms, reports, etc that you have in Access.
Now, any changes to the tables you see in this Access db ARE changes to the SQL Server database.

Resources