Tuesday, October 1, 2019

LINUX -- Installing SQL Server sqlcmd and bcp command-line tools on Oracle Linux 6

Currently working on a "SQL Server to Oracle Migration" project and dropping a useful installation method here.

Note that, I will prepare a detailed blog post for this migration later in the upcoming days. Stay tuned for this as well!

This blog post is about BCP (Bulk import-export utility)...

As a quick info, I want you to know that we are using SQL Developer (and sum manual/scriptized methods) to do this migration, and BCP is the tool used in the capture phase. (for capturing the data from SQL Server).. 

It is important to know that we are using Oracle Linux 6 to execute the migration methods, I mean to execute the tools used in this migration, including the SQL Developer 19.2 itself.

As you may guess, we (actually the SQL Deveoper) need a SQL Server-aware utility to bulk export the data in the first place.

This tool is BCP and it can be easily installed into an Oracle Linux using the Microsoft's yum repo prepared for RHEL 6.

Note that, we also need to install the unix ODBC development libraries along with the mssql-tools package in order to make things work...

Here is a demo;

[root@ermanserver ~]# curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/msprod.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
193 193 193 193 0 0 16 0 0:00:12 0:00:11 0:00:01 4825
[root@ermanserver ~]# yum install mssql-tools unixODBC-devel
Loaded plugins: refresh-packagekit, security, ulninfo
Setting up Install Process
packages-microsoft-com-prod | 2.9 kB 00:00
packages-microsoft-com-prod/primary_db | 68 kB 00:00
Resolving Dependencies
--> Running transaction check
---> Package mssql-tools.x86_64 0:17.4.1.1-1 will be installed
--> Processing Dependency: msodbcsql17 >= 17.3.0.0 for package: mssql-tools-17.4.1.1-1.x86_64
---> Package unixODBC-devel.x86_64 0:2.3.7-1.rh will be installed
--> Processing Dependency: unixODBC = 2.3.7 for package: unixODBC-devel-2.3.7-1.rh.x86_64
--> Running transaction check
---> Package msodbcsql17.x86_64 0:17.4.1.1-1 will be installed
---> Package unixODBC.x86_64 0:2.3.7-1.rh will be installed
--> Finished Dependency Resolution

Dependencies Resolved
==================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================
Installing:
mssql-tools x86_64 17.4.1.1-1 packages-microsoft-com-prod 286 k
unixODBC-devel x86_64 2.3.7-1.rh packages-microsoft-com-prod 42 k
Installing for dependencies:
msodbcsql17 x86_64 17.4.1.1-1 packages-microsoft-com-prod 795 k
unixODBC x86_64 2.3.7-1.rh packages-microsoft-com-prod 213 k

Transaction Summary
==================================================================================================================================================================================
Install 4 Package(s)

Total download size: 1.3 M
Installed size: 1.3 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): msodbcsql17-17.4.1.1-1.x86_64.rpm | 795 kB 00:00
(2/4): mssql-tools-17.4.1.1-1.x86_64.rpm | 286 kB 00:00
(3/4): unixODBC-2.3.7-1.rh.x86_64.rpm | 213 kB 00:00
(4/4): unixODBC-devel-2.3.7-1.rh.x86_64.rpm | 42 kB 00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.9 MB/s | 1.3 MB 00:00
warning: rpmts_HdrFromFdno: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Retrieving key from https://packages.microsoft.com/keys/microsoft.asc
Importing GPG key 0xBE1229CF:
Userid: "Microsoft (Release signing) <gpgsecurity@microsoft.com>"
From : https://packages.microsoft.com/keys/microsoft.asc
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : unixODBC-2.3.7-1.rh.x86_64 1/4
The license terms for this product can be downloaded from
https://aka.ms/odbc17eula and found in
/usr/share/doc/msodbcsql17/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
YES

Installing : msodbcsql17-17.4.1.1-1.x86_64 2/4
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746949 and found in
/usr/share/doc/mssql-tools/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
YES
Installing : mssql-tools-17.4.1.1-1.x86_64 3/4
Installing : unixODBC-devel-2.3.7-1.rh.x86_64 4/4
Verifying : msodbcsql17-17.4.1.1-1.x86_64 1/4
Verifying : unixODBC-devel-2.3.7-1.rh.x86_64 2/4
Verifying : mssql-tools-17.4.1.1-1.x86_64 3/4
Verifying : unixODBC-2.3.7-1.rh.x86_64 4/4

Installed:
mssql-tools.x86_64 0:17.4.1.1-1 unixODBC-devel.x86_64 0:2.3.7-1.rh

Dependency Installed:
msodbcsql17.x86_64 0:17.4.1.1-1 unixODBC.x86_64 0:2.3.7-1.rh
                                                         

At this point our demo installation is complete! Do not forget to add the directory (/opt/mssql-tools/bin/) where the bcp utility exist, to your PATH!.

No comments :

Post a Comment

If you will ask a question, please don't comment here..

For your questions, please create an issue into my forum.

Forum Link: http://ermanarslan.blogspot.com.tr/p/forum.html

Register and create an issue in the related category.
I will support you from there.