Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

SQL Server connect from Linux to Windows 2008

by anotherdj (Initiate)
on Jan 26, 2012 at 15:43 UTC ( #950136=perlquestion: print w/ replies, xml ) Need Help??
anotherdj has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I need some help on how to connect to a SQL Server database from one server to another.

A perl script is on a Ubuntu server which I need to read data from a SQL Server table on another server which is a Windows 2008 R2 64 bit.

On the Ubuntu server DBD::OBDC or DBD::W32OBDC are both installed.

From what I gather is the the connection string involves the creation of a DSN as the data source.

eg.
my $data_source = q/dbi:ODBC:datasource_name/;

What I'm not sure is how to create the data source in this case.

Do I create a DSN on the windows server or do I simply connect to the database with the server ip address and database name.

Usually if I run the script on the same server as the database I simply create the DSN.

Any guidance is appreciated.

Thank-you
David J.

Comment on SQL Server connect from Linux to Windows 2008
Re: SQL Server connect from Linux to Windows 2008
by Anonymous Monk on Jan 26, 2012 at 16:01 UTC
Re: SQL Server connect from Linux to Windows 2008
by thewebsi (Beadle) on Jan 26, 2012 at 21:28 UTC
Re: SQL Server connect from Linux to Windows 2008
by mje (Deacon) on Jan 27, 2012 at 10:00 UTC

    You can't use w32ODBC on Linux. You have 3 choices. DBD-Sybase (some restrictions on what you can do - read DBD::Sybase) and freeTDS/sybase libraries, DBI-ProxyServer (you'll need Perl on the Windows machine and it also has some restrictions) or DBD-ODBC, unixODBC and an ODBC Driver. freeTDS comes with an ODBC driver or there are a number of commercial ones. All this is covered in DBD::ODBC's FAQ linked to above including Do I need an ODBC driver?, What is the ODBC driver manager?, Where do I get an ODBC driver manager for Unix/Linux?, How do I access a MS SQL Server database from Linux/UNIX?

    If you go the ODBC route and your using your own Perl instead of the system one you'll need to install the unixodbc package and the unixodbc-dev package before making DBD::ODBC yourself or just install everything via the package manager into the system Perl.

    You could have easily found all this out yourself by searching for your question on Perl Monks before posting or by reading the FAQ for DBD::ODBC.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://950136]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-08-28 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (257 votes), past polls