Deprecated: Assigning the return value of new by reference is deprecated in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/cache.php on line 99

Deprecated: Assigning the return value of new by reference is deprecated in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/theme.php on line 576
Dirk.Net » Blog Archive » SQL Server with FreeTDS Unicode Data Error

Warning: mktime() [function.mktime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 19

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 28

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 30

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 32

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 33

Warning: mktime() [function.mktime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 19

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 28

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 30

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 32

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 33

SQL Server with FreeTDS Unicode Data Error

Ruby on Rails, SQL Server Add comments

Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/link-template.php on line 73

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/link-template.php on line 98

Deprecated: Function split() is deprecated in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-content/plugins/adsense-manager/adsense-manager.php on line 138

Deprecated: Function split() is deprecated in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-content/plugins/adsense-manager/adsense-manager.php on line 138

Deprecated: Function split() is deprecated in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-content/plugins/adsense-manager/adsense-manager.php on line 138

Update (Aug. 28, 2011): You may want to check out tiny_tds which obviates many of the below settings and gives you a richer and more scalable connection than ODBC.

If you get

Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.

when connecting to SQL Server from Linux via FreeTDS, you don’t set the FreeTDS version correctly.

To use SQL Server from Rails, I usually just create shared DSNs in /etc/odbc.ini (Ubuntu) with connection information that looks like so:

[SQLServerLocal]
Description  = FreeTDS
Driver  = FreeTDS
Server  = 192.168.0.1
Trace = No
Database  = my_database
TDS_Version = 8.0
Port  = 1433

Note the syntax: It must be Server, NOT Servername *Update: this only applies to the odbc.ini setup used here, if you need to read client charset = UTF-8 from freetds.conf, it has to be Servername, see update below* and TDS_Version has an underscore.

The standard ODBCConfig visual tool will usually set “Servername” instead of “Server” and this will not work.

The above settings should just work (provided FreeTDS is installed correctly) with the ActiveRecord SQL Server adapter and these settings in database.yml:

development:
adapter: sqlserver
mode: odbc
dsn: SQLServerLocal
database: my_database
username: some_user
password: secret
encoding: utf8

Also be sure to read general instruction on how to get Linux clients talk to SQL Server,  as well as the rails setup and connectivity for different clients.

Update: Turns out I still got errors such as

unixODBC][FreeTDS][SQL Server]Error converting characters into server’s character set. Some character(s) could not be converted

when using the “odbc.ini”-only setup outlined above.

It may be necessary to have the ODBC driver read the

client charset = UTF-8

from the /etc/freetds/freetds.conf file. And it can be set only there, not in the odbc.ini definition.

SO for example if you have this definition in your freetds.conf:

[sqlserver_local]
host = localhost
port = 1433
tds version = 8.0
client charset = UTF-8

the odbc.ini above has to be changed to:

[SQLServerLocal]
Description  = FreeTDS
Driver  = FreeTDS
Servername = sqlserver_local
Trace = No
Database  = my_database
TDS_Version = 8.0
Port  = 1433

Note that Server = has to be changed to Servername =. Hope it helps.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

2 Responses to “SQL Server with FreeTDS Unicode Data Error”

  1. Ken Collins Says:

    Switching to a dblib connection mode which uses TinyTDS for the SQL Server Adapter alleviates this problem since it can do all the correct encoding.

  2. dirk Says:

    @Ken: Thanks for your comment. I’ve updated the post after finding that tiny_tds is clearly better than ODBC.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in