venkata krishna Thaluru | 13 Jul 07:52 2014

Unclosed quotation mark

Hi All,
I am exporting data to MSSQL server and getting below error.

ODBC error (42000). [FreeTDS][SQL Server]Unclosed quotation mark after the
character string ' test

Could you please share your thoughts and ideas to resolve it or any know
issue in freeTDS ,please share it.

Venkata Krishna
Matevž Mrak | 11 Jul 08:31 2014

[unixODBC][Driver Manager]Function sequence error

I am using mxODBC with unixODBC and FreeTDS driver 8.0 on OSX to connect
MSSQL Server 2008 R2 on other Windows machine in network.

I can connect with python and execute queries but when creating database
with script I am getting this error:

InterfaceError: ('HY010', 0, '[unixODBC][Driver Manager]Function
sequence error', 5258)
 - File "/Users/matevzmrak/Desktop/praksa_fajli/projekt/ana/ana/srv/orm/",
line 101, in execute[0m[31m15:28:59.787 {unknown} - Query to
execute: sp_pkeys 'Currencies' - File
line 102, in execute

at this qry:


host =
port = 1433
tds version = 8.0
client charset = UTF-8


[ODBC Data Sources]
DSNmy    = mysqlDriver
(Continue reading)

Ola Karlsson | 6 Jul 15:32 2014

Problem with nvarchar output

I'm using Freetds with PHP5 to access a SQL server but I'm having trouble with the output parameters.
I have two parameters, one SQLINT4 and one SQLVARCHAR. The int is working but I don't get any returns from the varchar.

Is there anything special that needs to be done when outputting nvarchar?

PHP binds,
mssql_bind($stmt, ' <at> ErrorMsg',$ErrorMsg,SQLVARCHAR,true,false,4000);
mssql_bind($stmt, ' <at> OrderNr',$OrderNr,SQLINT4,true,true,8);

SQL parameters,
 <at> ErrorMsg nvarchar(4000) output
 <at> OrderNr Jeeves_OrderNo output

Sql server,
SQL Server 2008 R2

Freetds server,
Ubuntu 12.04 3.5.0-51-generic

Tsql -C
Version: freetds v0.91
freetds.conf directory: /etc/freetds
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
(Continue reading)

Frantisek Hanzlik | 5 Jul 11:46 2014

.dev.YYYY.mmdd hardcoded docdir?

A few days ago I wrote here about problems with bsqldb and fisql;
now I tried build last git2a830b1 version (because my Fedora 19 has
older version 0.91-gitf3ae29d (0a42888 ?) sometimes from November
2013, and I was hoping that new version will be working better).
But I have problem with making FreeTDS RPM package - it seems that
new git version ignore "--docdir" configure option and always install
doc into albeit right "/usr/share/doc/" directory, however here into
"" (where YYYYmmdd is actual date) - though
I was specifying "--docdir=/usr/share/doc/freetds-0.92".

It is intended, or I'm doing some mistake? IMO docdir (or other
package directories) should not depend on current date, but rather
on version ev. git subversion only }and should be configurable).

Thanks, Franta Hanzlik
Nem W Schlecht | 3 Jul 16:29 2014

Two issues with defncopy

Hello all!

Longtime user/admirer of the FreeTDS package, so first off I must
thank and praise everybody who has contributed to the development of
this extremely useful package. Thank you! :)

Secondly, I've had a couple of issues with 'defncopy' that I
investigated and fixed on my local copy, but want to know from the
developers if the changes I've made are stupid or not. :)

My first issue was that every now and then 'defncopy' would seem to
eat a space or two.  I'd have a stored procedure with a line like this
(in a SELECT):

     , some_field_name AS some_field_alias

Which would come out of 'defncopy' as:

     , some_field_nameAS some_field_alias

Which then throws an error upon re-loading into a database as the
field "some_field_nameAS" doesn't exist.  When the space *after* the
AS gets eaten, it'll reload successfully, but then my client will have
issues as the field alias is "ASsome_field_alias".

I've seen others report this issue on the internet and with a little
trial and error, I can now replicate the issue with the attached
stored procedure - where it will eat up 50 spaces and leave me with a
bad field alias. (dbo.defncopy_test.sql)  Just load this stored
procedure into tempdb and then dump it out via defncopy and the spaces
(Continue reading)

Frantisek Hanzlik | 2 Jul 18:33 2014

bsqldb crashes, fisql does not give the desired results

I'm absolute newbie in SQL, thus please forgive me if I do something
I tried run this script (which is working fine with
\Program Files\Microsoft SQL Server\90\Tools\Binn\osql.exe
from MS SQL server 2005 on Windows 2003 server) :

--- script begin
         <at> CityOd varchar(10),
         <at> CityDo varchar(10),
         <at> datumStavu datetime

set  <at> CityOd = 'ADAMOV'
set  <at> CityDo = 'WIEN'
set  <at> datumStavu = '2014-07-02'

create table #tmp(no_ varchar(20), up decimal(38,20),
s12 decimal(38,20), s14 decimal(38,20), s5416 decimal(38,20))
declare c cursor for
select No_, [Unit Price] from [MyDB$Item] k
where [Item Category Code] = 'E-SHOP'

declare  <at> no varchar(20),
         <at> up decimal(38,20),
         <at> s12 decimal(38,20),
         <at> s14 decimal(38,20),
         <at> s5416 decimal(38,20)

open c
fetch c into  <at> no,  <at> up
(Continue reading)

Eric Prud'hommeaux | 22 Jun 14:40 2014

(resent of an attempt 12 March 2014)

I wanted a wrapper which manage concurrent connections and provide a
vanilla interface like:

    MSSQL::Result r = sql.executeQuery(argv[i], &qeh);
    for (MSSQL::Result::iterator row = r.begin(); row != r.end(); ++row) {
        for (MSSQL::Values::const_iterator col = row->begin(); col != row->end(); ++col)
            std::cout << std::setw(col->size()) << col->lexical() << ' ';
        std::cout << "\n";

I didn't see one so I'm offering this to the community. main() (by
default) tests the concurrent access by executing all of the queries
on the command line at one and interleaving the results on the
console. This also fixes a small memory leak in samplecode.htm in that
it calls dbloginfree(login) after dbopen().

I preserved the (1)(2)... comments from samplecode.htm in case someone
with write access decides to make a parallel page for this version.


office: +1.617.599.3509
mobile: +

(eric <at>
Feel free to forward this message to any list for any purpose other than
email address distribution.

(Continue reading)

ericP | 22 Jun 15:16 2014

building freetds on windows

Some code base I'm working on (SWObjects, if you care) has a freetds
driver, as well as a few other database drivers. Apart from the
freetds driver, the rest of the code builds on Windows without a lot
of fiddling.

The freetds, which builds trivially on linux, seems to require some
extra infrastructure on Windows. The Nmake recipe

  nmake -fNmakefile -nologo apps PLATFORM=win32 CONFIGURATION=debug

works but doesn't build include/tds_sysdep_public.h from the .in.  I
figured that configure would run autoconf and generate the appropriate
files but /bin/sh is rare on Windows. I used the MINGW32 shell that
comes with gitshell but that whined about missing DLLs
(e.g. mspdb100.dll when runing MSVC's cl.exe, cygintl-2.dll when just
running configure).

I eventually copied tds_sysdep_public.h{.in,} and edited out all the
stuff with automake macros (the bottom half of the file). It built and
linked, but I haven't tested 'cause I'm not half smart enough to
configure MS SQL.

Presuming the above recipe worked and was necessary, I'd like to streamline it a bit by having windows
builds for autoconf files (well, at least the one that I needed). It seems more likely that I missed a simple
way for MSVC folks to do this (i.e. doesn't involve cygwin, ming, etc.).



(Continue reading)

Mark Lutgen | 5 Jun 16:12 2014

tsql having a hard time connecting to a MS SQL server

I'm having an issue on a Red Hat 5 64 bit server but I'm running a nearly
identical build on a Red Hat 4 32 bit. The error message is much like the
ones many others have complained about over the years but I've not seen one
matching this. Please allow me to show you below what happens:

In Bash as root:

export TDSDUMP=/var/log/freetds.log
export TDSDUMPCONFIG=/var/log/freetds_config.log

then I execute

tsql –S “SQLSERVER\TEST2000” -U readonly -P dbreadonly

It resolves the server name no problem but will not connect. The output is:

locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
16There was a problem connecting to the server

/var/log/freetds.log shows this:

log.c:196:Starting log file for FreeTDS 0.91
        on 2014-06-05 02:41:23 with debug flags 0x4fff.
iconv.c:330:tds_iconv_open(0x1eaea3b0, UTF-8)
iconv.c:187:local name for ISO-8859-1 is ISO-8859-1
iconv.c:187:local name for UTF-8 is UTF-8
iconv.c:187:local name for UCS-2LE is UCS-2LE
iconv.c:187:local name for UCS-2BE is UCS-2BE
(Continue reading)

Craig A. Berry | 30 May 20:32 2014

[PATCH] Don't return newline from VMS-specific readline.

readline is documented to return a line without the trailing
newline, but we haven't been doing this in our homegrown version
so would sometimes see doubled newlines in fisql.
 vms/getpass.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/vms/getpass.c b/vms/getpass.c
index b7d1ecb..d11c744 100644
--- a/vms/getpass.c
+++ b/vms/getpass.c
 <at>  <at>  -279,7 +279,7  <at>  <at>  getpass(const char *prompt)
 char *
 readline(char *prompt)
-	char *buf = NULL, *s = NULL, *p = NULL;
+	char *buf = NULL, *s = NULL, *p = NULL, *newline = NULL;
 	if (tds_rl_instream == NULL)
 		s = readpassphrase((const char *) prompt, passbuf, sizeof(passbuf),
 <at>  <at>  -290,6 +290,13  <at>  <at>  readline(char *prompt)
 		buf = (char *) malloc(strlen(s) + 1);
 		strcpy(buf, s);
+	/* readline is documented to eat the newline. */
+	if (buf) {
+		newline = strchr(buf, '\n');
+		if (newline)
+			*newline = '\0';
+	}
(Continue reading)

Craig A. Berry | 30 May 20:34 2014

[PATCH] Make fisql exit with failure when it fails.

It seems that the Sybase flavor of isql does not do this, but the
Microsoft flavor of isql and its descendants do.  But it's gosh
darn convenient when running fisql from a script to be able to
check whether it succeeded, and it isn't going to cause any trouble
for the interactive user, who is highly unlikely to be looking at
the exit status after running fisql.
 src/apps/fisql/fisql.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/apps/fisql/fisql.c b/src/apps/fisql/fisql.c
index ea420a1..f3fc4c0 100644
--- a/src/apps/fisql/fisql.c
+++ b/src/apps/fisql/fisql.c
 <at>  <at>  -268,6 +268,7  <at>  <at>  main(int argc, char *argv[])
 	int printedcompute = 0;
 	char adash;
 	const char *database_name = NULL;
+	int default_exit = EXIT_SUCCESS;

 	setlocale(LC_ALL, "");

 <at>  <at>  -588,7 +589,7  <at>  <at>  main(int argc, char *argv[])
 			    || (!(strcasecmp(firstword, "quit")))) {
-				exit(EXIT_SUCCESS);
+				exit(default_exit);
 			if (!(strcasecmp(firstword, "reset"))) {
(Continue reading)