String functions can be nested. For example, to display the last name and the first initial of each author living in Oakland, with a comma after the last name and a period after the first initial:
SELECT (au_lname ',' + '' + substring(au_fname, 1, 1) + '.') FROM authors WHERE city = 'Oakland' ---------------------- Green, M. Straight, D. Stringer, D. MacFeather, S. Karsen, L. (5 row(s) affected)
To display the pub_id and the first two characters of each title_id for books over $20:
SELECT substring(pub_id title_id, 1, 6) FROM titles WHERE price > $20
For details about other string functions, see Functions in the Microsoft SQL Server Transact-SQL Reference.