okay..so you are doing this (65) sql : EXPAND INSERT INTO rad_accts (tenant_id, acctsessionid, acctuniqueid, username, realm, nasipaddress, nasportid, nasporttype, acctstarttime, acctupdatetime, acctstoptime, acctsessiontime, acctauthentic, connectinfo_start, connectinfo_stop, acctinputoctets, acctoutputoctets, calledstationid, callingstationid, acctterminatecause, servicetype, framedprotocol, framedipaddress) VALUES (SELECT nas.tenant_id FROM nas WHERE nas.realipaddr = '%{NAS-IP-Address}', '%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', '%{NAS-Port-Type}', FROM_UNIXTIME(%{integer:Event-Timestamp}), FROM_UNIXTIME(%{integer:Event-Timestamp}), NULL, '0', '%{Acct-Authentic}', '%{Connect-Info}', '', '0', '0', '%{Called-Station-Id}', '%{Calling-Station-Id}', '', '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}') you cant do that - that is not a valid SQL INSERT command. you will need to either have a stored procedure in the SQL server for that first value.. OR, before you do the sql stuff you will need to assign a value to a local variable that you have defined in the dictionary file eg this_example = %{sql:"SELECT nas.tenant_id FROM nas WHERE nas.realipaddr = '%{NAS-IP-Address}"} and then use the this_example variable in your SQL INSERT statement obviously, read the unlang man page to see how to deal with such variables alan