Reputation: 11
I have and address table with the following columns:
What I want is to SELECT * from address where addressId = @addressId
, and that return would be all columns concatenated into one string. Something like:
set @addressString = (SELECT * from address where addressId = @addressId)
Upvotes: 1
Views: 3878
Reputation: 44316
select coalesce(cast(addressId as varchar)+ ',', '') + coalesce(buildingName+ ',', '')
coalesce(cast(streetNo as varchar)+ ',', '') -- + and so on
from address
remember to cast the numeric types as varchar
Upvotes: 4
Reputation:
Try this:
SELECT buldingName + ' ' + streetNo + ' ' + streetName + ' ' + theRestOfYourColumns AS ClientAddress
FROM YourAddressTable
WHERE addressId = @addressIdPreviouslyAssignedVariable
Upvotes: 0