Copy data from SQL Server to Oracle - sql-server

I have to copy data from several tables from SQL Server to Oracle. The tables have the same names on both DBs and the total number of rows to be copied is aboput 300 records. So some INSERT statements will be enough.
I tried using SSMS Tools. It generated me scripts with INSERT statements but the execution on Oracle fails because of the UNION clause (ORA-00923: FROM keyword not found).
Can someone recommand me another easy way to copy the data.
Thanx in advance

INSERT INTO tbl SELECT x UNION SELECT y UNION SELECT z isn't valid Oracle not because of the UNION, but because of the SELECTs.
You could simply change it to INSERT INTO tbl SELECT x FROM DUAL UNION SELECT y FROM DUAL UNION SELECT z FROM DUAL
You could quickly do this manually with a search and replace UNION with DUAL UNION and add one DUAL on the end.

To convert the Microsoft SQL Server database to Oracle, you need to create a repository to store the required repository tables and PL/SQL packages.
Have a look at this article
http://st-curriculum.oracle.com/obe/db/hol08/sqldev_migration/mssqlserver/migrate_microsoft_sqlserver_otn.htm
You also need to create database capture scripts as in here
http://st-curriculum.oracle.com/obe/db/hol08/sqldev_migration/mssqlserver/viewlets/sqlserver_capture.swf
These are in sqlserver.ocp format

There is a copy feature in SQL Server 4.1 - which does copy table from SQL Server to Oracle. For no so big tables, it works fine however, for larger tables you may get some errors.

This is in case of Migration of data from SQL server to Oracle. However, the concern here is just for getting copied sql server database to Oracle.

The question is about "NOT converting" - it is just copying the sql server database objects table to oracle. If you go to Tools Menu of the recent SQL Developer to you will see "database copy" however there is also a another feature "migration" on the same sql developer 4.1's tools menu
So Oracle SQL developer has two separate features - 1. Data Migration 2. Data copy
Look the sql developer's manual - you are talking Data Migration feature and question is all about "Copy"of table or tables data.

Related

SSIS, query Oracle table using ID's from SQL Server?

Here's the basic idea of what I want to do in SSIS:
I have a large query against a production Oracle database, and I need the following where clause that brings in a long list of ids from SQL Server. From there, the results are sent elsewhere.
select ...
from Oracle_table(s) --multi-join
where id in ([select distinct id from SQL_SERVER_table])
Alternatively, I could write the query this way:
select ...
from Oracle_table(s) --multi-join
...
join SQL_SERVER_table sst on sst.ID = Oracle_table.ID
Here are my limitations:
The Oracle query is large and cannot be run without the where id in (... clause
This means I cannot run the Oracle query, then join it against the ids in another step. I tried this, and the DBA's killed the temp table after it became 3 TB in size.
I have 160k id's
This means it is not practical to iterate through the id's one by one. In the past, I have run against ~1000 IDs, using a comma-separated list. It runs relatively fast - a few minutes.
The main query is in Oracle, but the ids are in SQL Server
I do not have the ability to write to Oracle
I've found many questions like this.
None of the answers I have found have a solution to my limitations.
Similar question:
Query a database based on result of query from another database
To prevent loading all rows from the Oracle table. The only way is to apply the filter in the Oracle database engine. I don't think this can be achieved using SSIS since you have more than 160000 ids in the SQL Server table, which cannot be efficiently loaded and passed to the Oracle SQL command:
Using Lookups and Merge Join will require loading all data from the Oracle database
Retrieving data from SQL Server, building a comma-separated string, and passing it to the Oracle SQL command cannot be done with too many IDs (160K).
The same issue using a Script Task.
Creating a Linked Server in SQL Server and Joining both tables will load all data from the Oracle database.
To solve your problem, you should search for a way to create a link to the SQL Server database from the Oracle engine.
Oracle Heterogenous Services
I don't have much experience in Oracle databases. Still, after a small research, I found something in Oracle equivalent to "Linked Servers" in SQL Server called "heterogeneous connectivity".
The query syntax should look like this:
select *
from Oracle_table
where id in (select distinct id from SQL_SERVER_table#sqlserverdsn)
You can refer to the following step-by-step guides to read more on how to connect to SQL Server tables from Oracle:
What is Oracle equivalent for Linked Server and can you join with SQL Server?
Making a Connection from Oracle to SQL Server - 1
Making a Connection from Oracle to SQL Server - 2
Heterogeneous Database connections - Oracle to SQL Server
Importing Data from SQL Server to a staging table in Oracle
Another approach is to use a Data Flow Task that imports IDs from SQL Server to a staging table in Oracle. Then use the staging table in your Oracle query. It would be better to create an index on the staging table. (If you do not have permission to write to the Oracle database, try to get permission to a separate staging database.)
Example of exporting data from SQL Server to Oracle:
Export SQL Server Data to Oracle using SSIS
Minimizing the data load from the Oracle table
If none of the solutions above solves your issue. You can try minimizing the data loaded from the Oracle database as much as possible.
As an example, you can try to get the Minimum and Maximum IDs from the SQL Server table, store both values within two variables. Then, you can use both variables in the SQL Command that loads the data from the Oracle table, like the following:
SELECT * FROM Oracle_Table WHERE ID > #MinID and ID < #MaxID
This will remove a bunch of useless data in your operation. In case your ID column is a string, you can use other measures to filter data, such as the string length, the first character.

How can I query two separate non-linked SQL Servers?

My goal is to pull data from 5 tables into one resultset, using a UNION Query.
Problem is that my tables are distributed across two separate servers (SQL Server v11.0 and SQL Server v13.0). They are not linked, they cannot be linked, and they have no relationship whatsoever.
Is there anyway to do that?
That is not going to happen in 11 and 13. But if it's really just a union you need, import to a staging area using bcp or your favorite ETL tool; if staging is in one or the other servers then you can union right there and save the transfer of any duplicates that would have been removed from the union (assuming we want a union and not union all).
You can try througt ACCESS. You can connect ACCESS with ODBC to both server, do a union in ACCESS and then upload the result where you want.
But this depend on the dimensions of the table of course.

Union view (query) between SQL Server and Oracle tables

I have 2 tables, one is in SQL Server, the other is in Oracle (this is driven by the software that feeds the databases and cannot be changed).
Currently I am using MS Access and have pulled both of these tables in as 'linked tables'. MS Access makes it very easy to pull in data from a variety of different data sources (Oracle, SQL Server, XML, Excel etc.) and then query as if the tables were in the same environment.
I want to have the same view in SQL Server. Is this possible?
The reason I want this is because as it stands, for anyone to use my MS Access query, they need the ODBC connections on their local workstations. Many of the workstations do not have the Oracle driver installed.
I want to push the ODBC requirement to a server and then just use a SQL Server view in the MS Access database and remove the linked tables. Every workstation has a SQL driver which would make this much easier for me.
**SQL Server** **ORACLE**
TABLE_A TABLE_B
Name Name
Description Description
VALUE1 VALUE1
STATUS STATUS
Union query in MS Access is:
SELECT DISTINCT *
FROM TABLE_A
UNION
SELECT DISTINCT *
FROM TABLE_B;
I want a view in SQL Server that replicates this Union query.
You need to create a "linked server" on SQL Serwer to Oracle database.
https://www.mssqltips.com/sqlservertip/4396/creating-a-sql-server-2014-linked-server-for-an-oracle-11g-database/
Then you will use a query like this:
SELECT DISTINCT *
FROM TABLE_A
UNION
SELECT DISTINCT *
FROM Oracle_link_server..schema.table_b;

Syncing Data from local database to online database SQL Server and VB.Net

Is there a way of syncing a local database to online database ?
Lets say, I have a local database with a bunch of data stored. When I click a button all data from my local database will be sync to my online database. I am using SQL Server 2012 and VB.Net.
Thank you.
As Squirrel recommend to use LINKED SERVER , a built-in feature of SQL Server Management Studio (I am using SSMS 2012) to enable the Database Engine to execute a Transact-SQL statement that includes tables in another instance of SQL Server, or another database product such as Oracle. see linked-servers. I am able to synchronize data using queries.
I achieve inserting data from local database to online database using the following queries:
INSERT INTO [linkedserverhostname].databasename.dbo.tablename
SELECT * From dbo.tablename Where Convert(Date, StartTime) = '08/26/2018'
EXPLANATION:
Insert into
INSERT INTO [linkedserverhostname].databasename.dbo.tablename
whatever the value of this select statement
SELECT * From dbo.tablename Where Convert(Date, StartTime) = '08/26/2018'
Same as the update and delete.
Look into SQL Server Replication Services.

Access Upsize to Sqlserver not transfer data

I have a Access Database with 11,000,000 records.I want to transfer this records to same table in Sqlserver 2008 using Upsize tools. This tool creates the database and tables correctly but the table in SQL Server is empty and data is not transferred.
Since you didn't mention receiving an error message, check the field types in the new SQL Server table to confirm they are compatible with their Access counterparts.
If it looks OK, start Access and create an ODBC link to the SQL Server table. Then create an Access "append query" to add data from the Access table to the SQL Server table.
INSERT INTO remote_table (field1, field2, field3)
SELECT field1, field2, field3
FROM local_table
WHERE date_field >= #2012-01-01# AND date_field < #2012-02-01#;
Note I imagined a WHERE clause which limits the number of rows to a reasonably small subset of the 11 million rows. Adjust as needed for your situation.
If that INSERT succeeds, repeat it with different WHERE conditions to append chunks of the data to SQL Server until you get it all transferred.
And if it fails, hopefully you will get an error message which explains why.
As noted here in most cases it is a bad date or simply a date that is outside of SQL server that cases a fail. I would suggest you use the Access migration tool as opposed to the built in tool. It does a MUCH better job.
You find this utility here:
http://www.microsoft.com/en-us/download/details.aspx?id=28763
The above tends to deal with the date and other issues that prevent data uploads far better than the built in upsize tool

Resources