How to transfer/migrate tables with schema from SQL Server to Oracle? - sql

I have tables from my SQL Server 2008 R2 that have a schema. I manage to transfer some tables to sql developer but the tables with schema did't transfer. How to do?.

You can use DTS (Data Transformation Service) at SQL Server Side or you can configure Gateway at oracle side. To Use DTS you should have oracle client on the machine where you are executing DTS.
DTS will ask you for source and destination and it's credential. So as you need to migrate from SQL to Oracle. In source tab select "Microsoft OLEDB Provide for SQL Server" as Data Source, Put IP Address / Server Name in Server Name DDown. If you have Window Authentication then let it be and select database and go to Next. If you have login ID and Password, select SQL Server Authentication put Login Id and Password, Select you database and then click on Next button.
In destination Tab select "Microsoft OLEDB Provider for Oracle", then click on Properties. And put TNSName into Server Name (You configured using NETCA in Oracle Client on the machine) and LoginId and Password.
After you get connected it will display to use query or complete table, you just click on next without selecting any option.
Then it will display all tables from source, select the table you need to migrate then click on next till finish.
For Gateway configuration, take help from this link.
https://docs.oracle.com/cd/B28359_01/gateways.111/b31043/conf_sql.htm
Thanks

Related

No PK or FK when exporting SQL Server database

We have a Production and a Staging database hosted on Microsoft Azure. We're using Microsoft SQL Server Management Studio 19 to do the migrating.
Here goes the steps
Right click the database -> Tasks -> Export Data...
We select SQL Server Native Client 11.0 as the Data Source.
For authentication we select "Use SQL Server authentication" and type in our user name and password.
In "Database", we select our Production database
After clicking Next, we'll now select our destination. For Destination we use "SQL Server Native Client 11.0" and the same setup as above, but just with our Staging database as destination.
Now it's time to "Specify Table Copy or Query" and here we select "Copy data from one or more tables or views".
We now mark all the tables and select Edit Mappings..., where we enable Enable identity insert.
If we then press Next and start the migration, everything seems to be completed without any errors or warnings.
BUT - For some reason all our PK and FK relations are not exported into our Staging database.
We have tried to look up a single table, just to see the SQL query which are generated and it looks like the image attached.
Can anyone tell us, what we're doing wrong. We have no idea, why the PK and FK's aren't migrated. Stored procedures and everything are working as expected.
There are two ways to export the PK and FK.
Using SSMS to generate the sql script. We just need to select the tables. It will generate a script.sql in your local PC.
2 We can query System tables and views to splicing FK and PK's SQL statement.

migrating multiple linked server from one server to another on sql server 2008 R2

I have 25 linked server(which will connect remote sql server 2000) working perfectly on one server, i even don't know login information of those linked server. My current environment is sql server 2008 R2, my new environment is also sql server 2008 R2 , i just need to migrate all linked server from old to new, preserving all login information
Possible?
If you're dealing with linked servers that have specific users specified with password then I don't think you'll be able to preserve that password information. Since linked servers are at the server level that information wouldn't be in any db backup. But, you could run queries like the one below to get the list of linked servers and check which ones use pass-through credentials. For the ones that do, just create new linked server definitions in the new database (you can easily get this SQL by right-clicking on the linked server in SSMS and generating the script). For the ones that don't, you can create the linked server via TSQL but you'll have to give them new credentials.
SELECT
serv.NAME,
serv.product,
serv.provider,
serv.data_source,
serv.catalog,
prin.name,
ls_logins.uses_self_credential,
ls_logins.remote_name
FROM
sys.servers AS serv
LEFT JOIN sys.linked_logins AS ls_logins
ON serv.server_id = ls_logins.server_id
LEFT JOIN sys.server_principals AS prin
ON ls_logins.local_principal_id = prin.principal_id

How to retrieve records from server database into local database

I have a little problem. I want to create a query in my local database (tijdsregistratie.mdf) to retrieve rows from my server database (IT Solutions Develop.dbo) on server itshou-dev03\sql2008.
But I don't know how to connect to the server database. I tried it like this :
select TOP 10 * from [IT Solutions Develop].dbo.[IT Solutions BVBA$Planning]
.. but it gives me this error :
Invalid object name 'IT Solutions Develop.dbo.IT Solutions
BVBA$Planning'.
One way is to link the servers:
http://msdn.microsoft.com/en-us/library/ms188279.aspx?ppud=4
You can also define linked servers by using SQL Server Management
Studio. In the Object Explorer, right-click Server Objects, select
New, and select Linked Server. You can delete a linked server
definition by right-clicking the linked server name and selecting
Delete.
This is the process by which you tell SQL Server where another server is and how to connect to it. You can do this in SQL Server Management Studio or in T-SQL. You can then refer to the linked server by a four part name (similar to what is in your question):
[LinkedServerName].[Database].[Schema].[Object]

ODBC Linked server in sql 2005 doesn’t work from remote box

I have a dev workstation with sql 2005 installed and in it I created a linked server to a odbc connection to a clarion database. I can run select statements against it inside sql Mgt studio. When I take a second workstation and connect to the sql on the first box using sql mgt studio, then try the exact same query I get
OLE DB provider "MSDASQL" for linked server "liveclarion" returned message "[SoftVelocity Inc.][TopSpeed ODBC Driver][ISAM]ISAM Table Not Found".
Any thoughts? It appears to have the same functionality on a second sql server. No remote sql mgt studio connect success in queries against my linked ODBC clarion DB.
All done with windows authentication and the same AD user.
The error returned by the ODBC driver is "SAM table not found".
So I'm assuming you have a table called SAM - presumably in a table called Sam.Tps?
I'm wondering if you need to set a path to that file - ie if there's some difference in path or file name validity between your two tests. One assumes not, but I'd look in that direction first.

How do you setup a linked server to an Oracle database on SQL 2000/2005?

I am able to create and execute a DTS package that copies tables from a remote Oracle database to a local SQL server, but want to setup the connection to the Oracle database as a linked server.
The DTS package currently uses the Microsoft OLE DB Provider for Oracle with the following properties:
Data Source: SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.3.42)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=acc)));uid=*UserName*;pwd=*UserPassword*;
Password: UserPassword
User ID: UserName
Allow saving password: true
How do I go about setting a linked server to an Oracle database using the data source defined above?
I was able to setup a linked server to a remote Oracle database, which ended up being a multi-step process:
Install Oracle ODBC drivers on SQL Server.
Create System DSN to Oracle database on SQL Server.
Create linked server on SQL server using System DSN.
Step 1: Install Oracle ODBC drivers on server
a. Download the necessary Oracle Instant Client packages: Basic, ODBC, and SQL*Plus (optional)
b. Unzip the packages to a local directory on the SQL server, typically C:\Oracle. This should result in a [directory] like C:\Oracle\instantclient_10_2, which will be the value of [directory] referenced in the rest of this answer.
c. Create a text file named tnsnames.ora within the instant client [directory] that contains the following:
OracleTnsName =
(
DESCRIPTION=
(
ADDRESS = (PROTOCOL=TCP)(HOST=10.1.3.42)(PORT=1521)
)
(
CONNECT_DATA = (SERVICE_NAME=acc)
)
)
Note: Actual HOST, PORT, and SERVICE_NAME will vary based on Oracle server you are establishing a connection to. This information can often be found using the Oracle network client tools under the listeners.
The OracleTnsName can be any name you want to assign to the Oracle data source, and will be used when setting up the system DSN. You can also use the syntax above to define multiple TNS names in the same tnsnames.ora file if desired.
d. Add the [directory] to the system PATH environment variable.
e. Create a new system environment variable named TNS_Admin that has a value of [directory]
f. Execute the [directory]\odbc_install.exe utility to install the Oracle ODBC drivers.
g. It is recommended that you reboot the SQL server, but may not be necessary. Also, you may want to grant security permissions to this directory for the SQL server and SQL agent user identities.
Step 2: Create a System DNS that uses the Oracle ODBC driver
a. Open the ODBC Data Source Administrator tool. [ Administrative Tools --> Data Sources (ODBC) ]
b. Select the System DSN tab and then select the Add button.
c. In the drivers list, select Oracle in instantclient {version}. (e.g. 'Oracle in instantclient 10_2') and then select Finish button.
d. Specify the following:
Data Source Name: {System DSN Name}
Description: {leave blank/empty}
TNS Service Name: should have the OracleTnsName you defined in the tnsnames.ora file listed, select it as the value.
User ID: {Oracle user name}
e. Select Test Connection button. You should be prompted to provide the {Oracle user password}. If all goes well the test will succeed.
Step 3: Create linked server in SQL to the Oracle database
Open a query window in SQL server and execute the following:
EXEC sp_addlinkedserver
#server = '{Linked Server Name}'
,#srvproduct = '{System DSN Name}'
,#provider = 'MSDASQL'
,#datasrc = '{System DSN Name}'
EXEC sp_addlinkedsrvlogin
#rmtsrvname = '{Linked Server Name}'
,#useself = 'False'
,#locallogin = NULL
,#rmtuser = '{Oracle User Name}'
,#rmtpassword = '{Oracle User Password}'
Note: The {Linked Server Name} can be anything you want to use when referencing the Oracle server, but the {System DNS Name} must match the name of the system DSN you created previously.
The {Oracle User Name} should be the same as the User ID used by the system DSN, and the {Oracle User Password} should be the same as you used to successfully test the ODBC connection. See KB 280106 for information on troubleshooting Oracle linked server issues.
Querying the Oracle linked server
You may use OPENQUERY to execute pass-through queries on the Oracle linked server, but be aware that for very large recordsets you may receive a ORA-01652 error message if you specify a ORDER BY clause in the pass-through query. Moving the ORDER BY clause from the pass-through query to the outer select statement solved this issue for me.
I had the same problem. I was on the phone with Microsoft for hours, and they did not have a solution. None of those "connection timeout" settings helped me.
To resolve it, I created a DTS job that runs a proc which only updates the time on one row, in one column, every two minutes. Then I setup a replication between SQL Server and Oracle, scheduled to replicate that single cell change, from SQL to Oracle, every 3 minutes. It keeps the connection alive!