The only phone company as of now that retains data on text messages is Verizon Wireless.
Verizon Wireless retains the text messages in their system for up to 5 days but other call detail records are kept for up to a year and for some other phone companies such as AT&T keeps call detail records for up to 7 years.