### TDS, using cdr_tds

Compile, configure, and install the latest FreeTDS package:

-     		   tar -zxvf freetds-0.62.4.tar.gz &&
      		   cd freetds-0.62.4 &&
      		   ./configure --prefix=/usr --with-tdsver=7.0
      		   make &&
      		   make install

Compile, or recompile, asterisk so that it will now add support for cdr_tds.

-                        make clean && ./configure --with-tds &&
                         make update &&
                         make &&
                         make install

Only install one database connector. Do not confuse asterisk by using both ODBC (cdr_odbc) and FreeTDS (cdr_tds). This command will erase the contents of cdr_odbc.conf

-     		[ -f /etc/asterisk/cdr_odbc.conf ] > /etc/asterisk/cdr_odbc.conf

Setup cdr_tds configuration files. These are working samples from my system. You will need to modify for your setup. Define your usernames and passwords here, secure file as well.

-                     /etc/asterisk/cdr_tds.conf
      		   [global]
      		   hostname=192.168.1.25
      		   port=1433
      		   dbname=voipdb
      		   user=voipdbuser
      		   password=voipdpass
      		   charset=BIG5

And finally, create the 'cdr' table in your mssql database.

-     		CREATE TABLE cdr (
      		        [accountcode]   [varchar] (20)          NULL ,
      		        [src]           [varchar] (80)          NULL ,
      		        [dst]           [varchar] (80)          NULL ,
      		        [dcontext]      [varchar] (80)          NULL ,
      		        [clid]          [varchar] (80)          NULL ,
      		        [channel]       [varchar] (80)          NULL ,
      		        [dstchannel]    [varchar] (80)          NULL ,
      		        [lastapp]       [varchar] (80)          NULL ,
      		        [lastdata]      [varchar] (80)          NULL ,
      		        [start]         [datetime]              NULL ,
      		        [answer]        [datetime]              NULL ,
      		        [end]           [datetime]              NULL ,
      		        [duration]      [int]                   NULL ,
      		        [billsec]       [int]                   NULL ,
      		        [disposition]   [varchar] (20)          NULL ,
      		        [amaflags]      [varchar] (16)          NULL ,
      		        [uniqueid]      [varchar] (150)         NULL ,
      		        [userfield]     [varchar] (256)         NULL
      		)

Start asterisk in verbose mode, you should see that asterisk logs a connection to the database and will now record every call to the database when it's complete.