我有以下列的地址表:
我想要的是SELECT * from address where addressId = @addressId
,并且返回将是连接成一个字符串的所有列。类似的东西:
set @addressString = (SELECT * from address where addressId = @addressId)
答案 0 :(得分:4)
select coalesce(cast(addressId as varchar)+ ',', '') + coalesce(buildingName+ ',', '')
coalesce(cast(streetNo as varchar)+ ',', '') -- + and so on
from address
请记住将数值类型转换为varchar
答案 1 :(得分:0)
试试这个:
SELECT buldingName + ' ' + streetNo + ' ' + streetName + ' ' + theRestOfYourColumns AS ClientAddress
FROM YourAddressTable
WHERE addressId = @addressIdPreviouslyAssignedVariable