Say I have a table with columns firstName and lastName. Is it possible to do an INSERT INTO newTable SELECT firstName, lastName FROM oldTable, but instead of having two columns in the resulting table, concatenate the two columns?
Similarly, is it possible to concatenate a column with a static string?
Yes, you'd do
SELECT LTRIM(RTRIM(ISNULL(firstName, '') + ' ' + ISNULL(lastName, ''))) FROM oldTable
this concatinates the firstName and lastName columns, as well as the static string ' ' in between
EDIT: added LTRIM(RTRIM(...)) so if firstName or lastName is null, result won't have leading or trailing space as a result from the static ' ' string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With