Hi,
>expand: "%{User-Name}@%{Mikrotik-Realm}" -> 'craign at wifi.co'
assign that to a temporary value
>(0) sql : expand: "%{%{User-Name}:-DEFAULT}" -> 'craign'
>(0) sql : SQL-User-Name set to "craign"
and change the SQL call so that SQL-User-Name is based on your temporary value
alan