5

I have a Perl script on a Linux (Ubuntu 8.10) machine and I need to write data to a SQL Server Database. I've been trying to use the DBD::ODBC module but I can't get it to connect. Where can I get a free/open source driver to use to use for the ODBC connection or is there another way to do this from Perl on Linux?

2 Answers 2

9

I connect to SQL Server 2005 with the stack of unixODBC, freeTDS (this is the driver) and DBD::ODBC.

After you install these components, edit /etc/unixODBC/odbc.ini to read like this:

[DNS]
Description = my database
Driver = /usr/lib/libtdsodbc.so #path to freeTDS driver
Server = ServerName
Database = DatabaseName
Port = 1433 #sql server default port
TDS_Version = 9.0 #9.0 is sql server 2005
try domain login = yes
try server login = yes
nt domain = DOMAIN

If all goes well, you should be able to connect with:

$dbh = DBI->connect('dbi:ODBC:DNS', "userName", "passWord");

Good luck!

Sign up to request clarification or add additional context in comments.

2 Comments

Per freetds.org/userguide/choosingtdsprotocol.htm, your comment may be wrong.
@RobKinyon, can't say for sure as I haven't used this software stack in a very long time. But this was working, with these settings, 7 years ago.
5

Use the DBD::Sybase module, at one point Sybase and MS SQL Server shared a common codebase.

You may also want to investigate the open source FreeTDS libraries. See the FreeTDS FAQ Question "Which Perl library should I use".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.