Robert Citek <
[hidden email]>
wrote:
> How can I replace an underscore ("_") in a field with a tab?
>
> This works but seems like suck a hack:
>
> $ sqlite3 foobar.db 'select replace(id,"_","{tab}") from bar;' |
> sed -e 's/{tab}/\t/'
>
> I was hoping for a char(9) or similar but couldn't find anything in
> the docs:
>
>
http://www.sqlite.org/lang_corefunc.htmlThere's no special SQLite function because none is needed. SQLite will
quite happily accept a string literal containing a TAB character. The
trick is to enter one on the command line - and that's an issue with the
shell, not with SQLite.
Assuming you use bash shell, try this:
sqlite3 foobar.db $'select replace(id,\'_\',\'\t\') from bar;'
or
echo -e "select replace(id,'_','\t') from bar;" | sqlite3 foobar.db
But if you insist on doing it in SQL, this should work:
sqlite3 foobar.db "select replace(id,'_',cast(x'09' as text)) from bar;"
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users