BCP utility on linux: NativeError = 18456 Error = [unixODBC][Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user - sql-server

Following BCP example (installed on CentOS7 via https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-2017#a-idrhelainstall-tools-on-rhel-7 with the msodbcsql driver from https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017) for importing flatfile from linux to a MSSQL Server (https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-migrate-bcp?view=sql-server-2017#import-data-from-the-source-data-file), getting error when trying to run basic command to write a flatfile from local machine (CentOS7) to a remote (Windows Server 2012) host DB.
The script being used for testing here looks like:
[me#mapr001 examples]$ cat simple-bcp-tsv2mssql.sh
#!/bin/bash
TO_SERVER_ODBCDS="-D -S 'ODBC Driver 17 for SQL Server'"
TO_SERVER_IP="-S 172.17.9.29"
DB="DB_ML"
TABLE="bcp_test"
USER=""
PASSWORD=""
DATAFILE="./data/simple-rows.headless.tsv"
read -r -p "Enter username: " USER
read -r -s -p "Enter user password: " PASSWORD
echo -e "\nConnecting with BCP utility as $USER..."
/opt/mssql-tools/bin/bcp "$TABLE" in "$DATAFILE" \
"$TO_SERVER_DNS" \
-U "$USER" \
-P "$PASSWORD" \
-d "$DB" \
-c \
-t "'\t'"
and is throwing the (seemingly misleading) error
[me#mapr001 examples]$ ./simple-bcp-tsv2mssql.sh
Enter username: me
Enter user password:
Connecting with BCP utility as me...
/opt/mssql-tools/bin/bcp: unknown option
usage: /opt/mssql-tools/bin/bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
...
even though I appear to be following this usage format in the script. The results when running via commandline are what I think I should really be focusing on:
[me#mapr001 examples]$ bcp bcp_test in ./data/simple-rows.headless.tsv -D -S MyMSSQLServer -U me -P mypassword -d DB_ML -c -t '\t'
SQLState = 28000, NativeError = 18456
Error = [unixODBC][Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'me'.
The /etc/odbc/odbc files on this machine look like
# Referencing some of the ODBC setup steps here: https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-RHEL-6-or-Centos-7
# Prepare a temp file for defining the DSN to your database server
vi /home/user/odbcadd.txt
[MyMSSQLServer]
Driver = ODBC Driver 17 for SQL Server
Description = My MS SQL Server
Trace = No
Server = 172.17.9.29
# register the SQL Server database DSN information in /etc/odbc.ini
sudo odbcinst -i -s -f /home/me/odbcadd.txt -l
[me#mapr001 examples]$ cat /etc/odbc.ini
[MyMSSQLServer]
Driver=ODBC Driver 17 for SQL Server ------------
Description=My MS SQL Server |
Trace=No |
Server=172.17.9.29 |
|
[MyMSSQLServer_ML] |
Driver=ODBC Driver 17 for SQL Server |
Description=My SQL Server (ML DB) |
Tracec=No |
Server=172.17.9.29 |
Database=DB_ML |
|
|
[me#mapr001 examples]$ cat /etc/odbcinst.ini |
[PostgreSQL] |
Description=ODBC for PostgreSQL |
Driver=/usr/lib/psqlodbcw.so |
Setup=/usr/lib/libodbcpsqlS.so |
Driver64=/usr/lib64/psqlodbcw.so |
Setup64=/usr/lib64/libodbcpsqlS.so |
FileUsage=1 |
|
[MySQL] |
Description=ODBC for MySQL |
Driver=/usr/lib/libmyodbc5.so |
Setup=/usr/lib/libodbcmyS.so |
Driver64=/usr/lib64/libmyodbc5.so |
Setup64=/usr/lib64/libodbcmyS.so |
FileUsage=1 |
|
[ODBC Driver 17 for SQL Server] <----------------
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1
UsageCount=1
[me#mapr001 ~]# odbcinst -q -d -n "ODBC Driver 17 for SQL Server"
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1
UsageCount=1
[me#mapr001 ~]# odbcinst -j
unixODBC 2.3.1
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /etc/odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
The problem appears to be related to how I've setup ODBC drivers and configs or with my credentials (which are Active Directory credentials that I use to login to the remote Windows machine hosting the SQL Server I'm trying to connect to here), but I have zero experience setting this kind of thing up and at this point am at a bit of a loss as to what to do (will continue researching and debugging). Any advice on how to further debug or fix the problem would be appreciated.

The problem appears to be that the bcp utility expects credentials for the SQL Server (see https://learn.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-2017#U and https://learn.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-2017#T), not the crednetials for the host machine that the SQL Server is running on.
In my original post, was using the domain Active Directory creds. that I would normally use to login to the machine (which, again, is wrong (further supported here: https://www.sqlservercentral.com/Forums/FindPost1565871.aspx)). Using a separate set of SQL Server credentials instead in the command solved my problem. (Still don't get why the script is throwing "unknown option" error, so if anyone has a guess, please leave a comment).
UPDATE: After some "binarysearch debugging" (https://www.codelord.net/2012/04/10/using-binary-search-for-debugging/), found that the problem was that the field_term option (https://learn.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-2017#t) was formatted in a way that was causing some problems. Originally wrote the code in the script as -t "'\t'". Changing this to -t "\t" (no inner single quotes) fixed the problem. Note that this was hard to immediately catch because when echoing both versions of the command printed to the console exactly the same.

Related

How to fix Microsoft ODBC Driver 17 for SQL Server : SSL Provider ssl_choose_client_version:unsupported protocol

I have installed Sql Server 2019 Developer Edition and mssql-tools on my Ubuntu 20.04 minimal.
I can connect to my localhost with no issue, but when I want to remote to another sql server:
sqlcmd -S <server> -U <username> -P <password>
I face this error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
I has this issue once in Debian 10, and also search the net for solution, so after that I change my openssl.conf manually (su permission needed):
nano /etc/ssl/openssl.cnf
and add these to my file:
ess_cert_id_alg = sha1 under the [tsa_config1] heading
openssl_conf = default_conf near the top
the following at the end:
[default_conf]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
MinProtocol = TLSv1.0
CipherString = DEFAULT#SECLEVEL=1
I know that MinProtocol and CipherString are normally set to TLSv1.2 and DEFAULT#SECLEVEL=2, but as I mentioned once in my Debian 10, I edited my openssl.conf and change TLSv1.2 to TLSv1.0 and DEFAULT#SECLEVEL=2 to DEFAULT#SECLEVEL=1 and my connection fixed, but in Ubuntu 20.04 minimal not only there wasn't these lines, but also when I insert these manually again I face the same error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
my opnessl version is:
OpenSSL 1.1.1f 31 Mar 2020
I also downgrade my openssl once to 1.0 but it didn't work either!
I couldn't find anything else so I came here to ask for help, appreciate your help.
1.1.1m save my life. Install it manually.
The manual installation looks like:
wget https://www.openssl.org/source/latest.tar.gz -O openssl-1.1.1h.tar.gz
tar -zxvf openssl-1.1.1m.tar.gz
cd openssl-1.1.1m
./config
make
sudo make install
openssl version
sudo ldconfig
Try to add -C option to trust the server certificate:
sqlcmd -S <server> -U <username> -P <password> -C
For more details, please check my answer here: https://stackoverflow.com/a/73443215/970830

sqlcmd works in CMD and not in bash

I am having quite a few problems making MSSQL drivers work in Ubuntu. I have followed the following tutorial to make sqlcmd work in Ubuntu 16.04.
# In CMD:
sqlcmd -S my_server_name -U my_username -P my_password -d my_database
1> select name from sys.databases
2> go
After installing the same tool in Ubuntu, it seems to work, but it timeouts when attempting to connect to the same database:
# In Ubuntu bash
sqlcmd -S my_server_name -U my_username -P my_password -d my_database
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2AFA.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
I have tried to change configurations of the database, such that the port is static at 1433, but still no luck.
Do you have any suggestions?
I have fixed the problem!
1. Install MSSQL drivers on Ubuntu
Follow this tutorial.
2. Ensure your port on the database is static
Follow this tutorial to set up a static port.
3. Identify the IP adress of your database
I had to call the following code on the database to get the ip-adress: local_net_address.
SELECT
+ CONNECTIONPROPERTY('net_transport') AS net_transport,
+ CONNECTIONPROPERTY('protocol_type') AS protocol_type,
+ CONNECTIONPROPERTY('auth_scheme') AS auth_scheme,
+ CONNECTIONPROPERTY('local_net_address') AS local_net_address,
+ CONNECTIONPROPERTY('local_tcp_port') AS local_tcp_port,
+ CONNECTIONPROPERTY('client_net_address') AS client_net_address
4. Connect to database (in Ubuntu bash)
Here are two examples with netcat and sqlcmd.
# Using MSSQL tool
sqlcmd -S my_server_ip_adress//my_server_name,my_port -U my_username -P my_password -d my_database
# Using netcat
nc -z -v -w5 my_server_ip_adress my_port

Connecting Mac Sierra to SQL Server with isql

I'm trying to connect to SQL Server database from my Mac. Here's how I configured my drivers:
--- /etc/freetds/freetds.conf ---
[TS]
host = MISSDBServer01.xxxxxxxx.com
port = 1433
tds version = 7.0
client charset = UTF-8
--- /etc/odbcinst.ini ---
[FreeTDS]
Description = FreeTDS
Driver = /usr/local/lib/libtdsodbc.so
--- /etc/odbc.ini ---
[TS]
Driver = FreeTDS
Server = db.ip.add.ress
ServerName = xxxxAB288
Port = 1433
TDS_Version = 7.0
Everything is fine when I try to connect through tsql:
tsql -S TS -U user -P pass
locale is "en_GB.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> select ##version
2> go
Microsoft SQL Server 2012 (SP3) (KB3072779) - 11.0.6020.0 (X64)
Oct 20 2015 15:36:27
Copyright (c) Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
(1 row affected)
1> exit
But when I tried to connect using isql, I get this error:
isql -v TS user pass
[IM002][unixODBC][Driver Manager]Data source name not found, and no default driver specified
[ISQL]ERROR: Could not SQLConnect
I followed suggestions listed here and here, and as my end goal is to connect to MS SQL Server through R, also tried solutions from here and here.
UPDATE
following #Jim 's suggestion I ran odbcinst -j to get the config files directories:
unixODBC 2.3.4
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /Users/USERNAME/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
But when I go to /etc folder I can't find them there.. why?
When I run odbcinst -q -d I get odbcinst: SQLGetPrivateProfileString failed with Unable to find component name.. I tried to fix it by creating and editing .bash_profile file, as suggested here, but it made no difference.
When I run odbcinst -q -s I get odbcinst: SQLGetPrivateProfileString failed with . but at this point I'm really not sure what to do about it...
I'll appreciate any suggestions how to make it work! thanks!

BCP neither gives results nor outputs anything when using valid statements but it does throw errors when passing invalid parameters

I have to use bcp command-line tool to export data from an SQL Server database to a file in a Red Hat server.
I am (apparently) using valid statements but bcp is not producing any kind of output/results.
However, when I execute statements with missing or invalid parameters it displays the respective error.
I am looking for the reason of this issue (e.g. defective installation, bad usage of bcp, lack of permissions or any other known conflict) and how to fix it.
bcp statement:
bcp fully_qualified_table_name out ./data.txt -c -S server -U user -P password
bcp usage:
usage: /opt/microsoft/bin/bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-q quoted identifier]
[-t field terminator] [-r row terminator]
[-a packetsize] [-K application intent]
[-S server name or DSN if -D provided] [-D treat -S as DSN]
[-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"] [-d database name]
bcp version:
BCP - Bulk Copy Program for Microsoft SQL Server.
Copyright (C) Microsoft Corporation. All Rights Reserved.
Version: 11.0.2270.0
SQL Server version (SELECT ##VERSION):
Microsoft SQL Server 2012 - 11.0.5058.0 (X64)
May 14 2014 18:34:29
Copyright (c) Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)
Distribution:
Red Hat Enterprise Linux 6.7 (KornShell).
Invalid statements with respective error message (examples).
bcp THAT_TUB_ACE.oh_nerd.table_name out ./data.txt -c -S sr._bear -U you_sr. -P pass_sword
SQLState = S1T00, NativeError = 0
Error = [unixODBC][Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired
SQLState = 08001, NativeError = 11001
Error = [unixODBC][Microsoft][ODBC Driver 11 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
SQLState = 08001, NativeError = 11001
Error = [unixODBC][Microsoft][ODBC Driver 11 for SQL Server]TCP Provider: Error code 0x2AF9
...
bcp fully_qualified_table_name ./data.txt -c -S valid_server -U valid_user -P bad_word
bcp fully_qualified_table_name out ./data.txt -c -S valid_server -U valid_user -P bad_word
SQLState = 28000, NativeError = 18456
Error = [unixODBC][Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user 'valid_user'.
SUMMARY.
The objective is to generate a datafile using the following syntax (or similar):
bcp fully_qualified_table_name out ./data.txt -c -S server -U user -P password
The facts are:
When running a valid bcp statement there's nothing in the window at all (no output) and no datafile is created.
I cannot use option -T (trusted connection using integrated security) for bcp so I have to specify the server, user and password.
Tried queryout option on a very simple small table already but still no luck.
Credentials are valid, I successfully tested them using sqlcmd like the following: sqlcmd -S server -U user -P password -Q 'SELECT * FROM really_small_table'.
The bcp statements under "Invalid statements with respective error message (examples)" section of this question are just examples of invalid statements to show that bcp actually does something but giving the expected results.
Hopefully you've already solved your problem, but I had a similar problem configuring PyODBC for Python 3.4 on RedHat 7.1. I was trying to connect to Microsoft SQL Server 2016. Hopefully this will help someone else.
The real problem for me was ODBC/FreeTDS configuration. Here are the installation steps I took and the eventual solution.
I started by installing Microsoft's ODBC driver for redhat. This likely isn't required, but I list it here since I never removed it from my redhat machine for fear of breaking ODBC.
Install ODBC and ODBC development files: yum install unixODBC-devel.x86_64
Install FreeTDS: yum install freetds.x86_64
Update config files. Steps 1-3 took about 10 minutes. I spent a very frustrating day trying various configurations, and usually I was able to connect via tsql (FreeTDS debugging tool, more on that below), but never via Python. I eventually stumbled upon this blog, which pointed me to the correct driver via ldconfig -p | grep libtdsodbc (I believe this points to the FreeTDS driver, hence why Microsoft's driver probably isn't needed).
The eventual configuration I ended up with is as follows:
/etc/odbc.ini (note: I had to create this file as the ODBC/FreeTDS installation process didn't create it for me.)
[SQLServer]
Description = TDS driver (Sybase/MS SQL)
Driver = SQLServer
Servername = your_sql_hostname
TDS Version = 0.95
Database = your_database_name (not to be confused with instance name)
Port = 1433
/etc/odbcinst.ini
[ODBC]
# Enables ODBC debugging output. Helpful to see where things stop working.
Trace = yes
TraceFile = /etc/odbcinst.trace
[SQLServer]
Description=TDS driver (Sybase/MS SQL)
Driver=/lib64/libtdsodbc.so.0
Driver64=/lib64/libtdsodbc.so.0
UsageCount=1
Troubleshooting tips
tsql is debugging/testing tool that comes with FreeTDS. It is your friend. I was able to use it early on to verify that the networking side of things was correct (i.e. no firewalls blocking access, hostnames resolve, etc).
Use tsql -H your_sql_hostname -L to get the instance names and ports from your SQL server. Note that you'll use port 1433 (which is the MS SQL instance discovery port) in your ODBC configuration above, not these port numbers.
ServerName your_sql_hostname
InstanceName instance_1_name
IsClustered No
Version 13.0.x.x
tcp 5555
ServerName your_sql_hostname
InstanceName instance_2_name
IsClustered No
Version 13.0.x.x
tcp 6666
Use the port from the previous tsql command like so:
tsql -H your_sql_hostname -p your_sql_instance_port -D your_database_name -U your_username -P your_password
You should get a prompt. Try querying some data from your database (note that you have to type GO on a separate line to actually run your query). If this works but you still can't connect via Python/other-app, it usually means ODBC/FreeTDS are installed correctly and there are no networking problems, but your ODBC configuration isn't correct.
1> SELECT TOP 1 * FROM your_table
2> GO
{a row will be returned here}
1> # prompt returns, use `exit` to get out

How to connect ms sql database using perl in Windows?

I want to connect ms sql database through perl language. The following steps are I made.
I've created a database table in the name "SampleDb"
Configured ODBC and I've set name for sql server driver as "SampleDb"
Now I've tried to connect as follows,
,
my $dbs = "dbi:ODBC:DRIVER={SQL Server};SERVER={SampleDb}";
my $dbh = DBI->connect($dbs, "username", "password");
But Now I got the following error
DBI connect('DRIVER={SQL Server};SERVER={SampleDB}','username',...) failed: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. (SQL-08001) [state was 08001 now 01000]
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). (SQL-01000)
How to solve this ? or
How to Connect ms sql using perl through ODBC ?
This question has already been answered (and accepted !!). Just providing detailed steps for connecting MSSQL server from perl running on Linux using ODBC.
Before you get into perl stuff, you need to install and configure odbc environment on the Linux box.
Install below packages:
Fedora:
unixODBC-devel.i686
unixODBC.i686
AND
freetds.i686
freetds-devel.i686
freetds-doc.i686
Ubuntu:
unixodbc
unixodbc-dev
AND
freetds-bin
freetds-common
freetds-dev
tdsodbc
After these packages are installed we MUST be able to use freetds to test authentication network authentication with the MS SQL server.
root#ubuntu:/home# tsql -S <db_host_name> -p 1433 -U perluser -P password
locale is "en_IN"
locale charset is "UTF-8"
1>
If above fails, then check the MSSQL db permission for this user. Also check MSSQL logs. Do not proceed until you run above command successfully. Also, failure of above command has nothing to do with the unixodbc OR freetds configuration.
Configure the odbc.ini and odbcinst.ini and freetds.conf files.
/etc/odbc.ini will contain the DSN information:
root#ubuntu:/home# cat /etc/odbc.ini
[odbc-test]
Description = test
Driver = ms-sql
Servername = ms-sql
Database = <db_name>
UID = perluser
Port = 1433
Please note that, the Driver field refers to /etc/odbcinst.ini context named [ms-sql].
The Servername field refers to the /etc/freetds.conf context that I also named [ms-sql].
Database field is optional but I am using it as I want to connect to a particular Database.
/etc/odbcinst.ini file contains the Driver information:
root#ubuntu:/home# cat /etc/odbcinst.ini
[ms-sql]
Description = TDS Conection
Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so
UsageCount = 1
FileUsage = 1
The odbcinst.ini file simply directs the odbc.ini file to the appropriate driver.
The Driver and Setup entries for Fedora is /usr/lib/libtdsodbc.so and /usr/lib/libtdsS.so respectively.
Also, for 64-bit Linux box, it would be Driver64 and Setup64 instead of Driver and Setup respectively.
Configure /etc/freetds/freetds.conf ( /etc/freetds.conf for Fedora). It contains TDS information. Here is mine:
root#ubuntu:/home# tail /etc/freetds/freetds.conf
[ms-sql]
host = <db_host_name>
port = 1433
tds version = 7.0
dump file = /var/log/freetds.log
Please note that, above context name [ms-sql] is the value of Servername in odbc.ini.
Test the configuration by connecting the MSSQL server using isql command:
root#ubuntu:/home# isql -v odbc-test perluser password
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
The odbc-test portion of the isql command was defined in the odbc.ini file.
You HAVE to receive above output which says Connected!. If you don’t, then there is some problem in your configuration and go through all the above steps again.
Now,
Install Perl DBI module.
Install DBD::ODBC module .
Then use the ODBC in your perl code as below:
my $dbh = DBI->connect ('dbi:ODBC:odbc-test', 'perluser', 'password');
Hope This Helps.
This is for connecting MSSQL using perl in Windows.
Instead of ODBC, try OLEDB. The following code will help you.
my $host = 'sample\sql';
my $database = 'SampleDB';
my $user = 'sa';
my $auth = 'password';
$dsn = "Provider=sqloledb;Trusted Connection=yes;";
$dsn .= "Server=$host;Database=$database";
my $dbh = DBI->connect("dbi:ADO:$dsn",$user,$auth,{ RaiseError => 1, AutoCommit => 1}) || die "Database connection not made: $DBI::errstr";
Reference How to connect Ms Sql using Perl

Resources