Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others


0 votes
in Technique[技术] by (71.8m points)

linux - Perl connection with mssql server

I'm new to Perl. I'm trying to connect to MSSQL 2016 from Perl. Below is the code I have written and it is working fine in my personal account .

Where as in my organization account MS-MSQL server is running in different machine and I want to connect to it .

Note: running this in Linux machine

#!/usr/bin/perl -w
use strict;

use DBI;

my $user = 'SA';
my $password = '';

my $dbh = DBI->connect('dbi:ODBC:Driver={/opt/microsoft....};Server=localhost;Database=testsb;UID=$user;PWD=$password')
    or die "Can't connect ";

My question is where will I get this driver path since server is running in different machine. Please help ..

Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You don't change the path to the driver. That path is local to the machine where your Perl script is running. It's the SQL Server that's remote, so you need to change the Server=localhost section to use the hostname (or better, FQDN) to the remote server.

Also, maybe it's a Linux thing, but in Windows I just have to specify the driver like DBI:ODBC:Driver={SQL Server}, so there's no path involved at all.

Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share