AZone2Adapter].[dbo].[_data_OrganizationCustomerSpecialties] ( [Id], [OrganizationCustomerId], [SpecialtyId])
Как вывести все столбцы с условием в скрипте.?DECLARE @TextProduct NVARCHAR(MAX);
SELECT @TextProduct = ISNULL(@TextProduct + ', ','') + QUOTENAME([OrganizationCustomerId])
FROM [AZone2Adapter].[dbo].[_data_OrganizationCustomerSpecialties]
WHERE [OrganizationCustomerId]='1002775640209670'
SELECT @TextProduct AS TextProduct
Если написать:SELECT @TextProduct = ISNULL(@TextProduct + ', ','') + QUOTENAME([OrganizationCustomerId]),[Id]
STRING_AGG
не работает, только для SQL Server 2017 DECLARE @TextProduct NVARCHAR(MAX);
SELECT @TextProduct = CONCAT_WS( ', ', @TextProduct, [OrganizationCustomerId])
FROM [AZone2Adapter].[dbo].[_data_OrganizationCustomerSpecialties]
WHERE [OrganizationCustomerId]='1002775640209670'
SELECT @TextProduct AS TextProduct
Microsoft SQL Server 2008
DECLARE @TextProduct NVARCHAR(MAX);
SELECT @TextProduct = STUFF(COALESCE(', ' + @TextProduct, '')
+ COALESCE(', ' + [OrganizationCustomerId], ''), 1, 2, '')
FROM [AZone2Adapter].[dbo].[_data_OrganizationCustomerSpecialties]
WHERE [OrganizationCustomerId]='1002775640209670'
SELECT @TextProduct AS TextProduct