我想在以下选择查询中 VM.Address 和 VM.City 之间添加逗号
DECLARE @Address NVARCHAR(MAX);
set @Address = ' SELECT [Address] = CONCAT(VM.Address,' ', VM.City)
FROM [dbo].[VendorMaster] VM
WHERE IsActive = 1 AND VendorID = 6
ORDER BY VendorName'
EXECUTE SP_EXECUTESQL @Address
答案 0 :(得分:3)
尝试在地址和城市中间的引号内使用逗号:
set @Address = ' SELECT [Address] = CONCAT(VM.Address,'+''','''+', VM.City)
答案 1 :(得分:0)
尝试
set @Address = ' SELECT [Address] = STUFF(VM.Address + COALESCE(', ' + VM.City, '') , 1, 2, '')