in reply to Re^2: How to interpret characters in Devel::Peek CUR
in thread How to interpret characters in Devel::Peek CUR

As I previously commented here, much depends on the way you set up the connection, and there is still room to play with server-side encodings:

I recently worked from perl on Linux with a MS SQL server database, and got the best results with FreeTDS:

my $dbh = DBI->connect ("dbi:ODBC:mssql_freetds", $username, $password +, \%dbi_attributes);
$ cat ~/.odbc.ini [mssql_freetds] Description = My MS SQL database Driver = FreeTDS TDS version = 7.2 Trace = No Server = mysql.server.local Port = 1433 Database = DatabaseName User = UserName Password = PassWord Client Charset = UTF-8

The biggest difference between FreeTDS and the MS ODBC driver is the return type of UUID field. The MS ODBC does not allow nested queries, whereas the FreeTDS driver does. So I used the ODBC driver to make a CSV dump of the database and the FreeTDS driver to actually work with the database.

For ODBC I did

my $dbh = DBI->connect ("dbi:ODBC:mssql_odbc", $username, $password, \ +%dbi_attributes);
$ cat ~/.odbc.ini [mssql_odbc] Description = My MS SQL database Driver = ODBC Driver 17 for SQL Server Server = mysql.server.local Database = DatabaseName User = UserName Password = PassWord

Also make sure you put the fully qualified hostname in the server name. localhost will not work.


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^4: How to interpret characters in Devel::Peek CUR
by ait (Hermit) on Jun 16, 2020 at 15:13 UTC

    Thanks Tux for your detailed response on the drivers ! After reading your response I am regretting not having looked at FreeTDS. We have to open a bunch of separate connections for sub-queries and have had all sorts of issues and quirks on truncation, and not sure if the stupid ODBC driver is doing some strange padding, etc. Anyway, we are almost done with this work and too late to change driver, but I wish I would have asked here an opinion on DBI and SQLServer before engaging this project :-(