Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 ..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...