Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
nayanancha
Starting Member
27 Posts |
Posted - 2011-11-03 : 13:59:40
|
I have a stored proc which brings down the folowing result:I want the column to coming in a single row with comma seperated values.Thanks,set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER proc [dbo].[proc_GetFrontEndVendors] @Mode varchar(10)asbegin declare @CompanyTable varchar(200), @CompanyVendorTable varchar(200), @FrontendVendorTable varchar(200), @Sql nvarchar(1000), @Param nvarchar(1000) if(@Mode='live') begin set @FrontendVendorTable = 'Portal.dbo.FrontendVendor' set @CompanyTable = 'Portal.dbo.Company' set @CompanyVendorTable = 'Portal.dbo.CompanyVendor' end else begin set @FrontendVendorTable = 'Portal_Sandbox.dbo.FrontendVendor' set @CompanyTable = 'Portal_Sandbox.dbo.Company' set @CompanyVendorTable = 'Portal_Sandbox.dbo.CompanyVendor' end set @Sql = N'select FV.Id, FV.VendorName, FV.VendorCode, FV.VendorAddress, FV.ContactPerson, FV.ContactEmail, FV.ContactPhone, C.CompanyCode from ' + @CompanyTable + ' C inner join ' + @CompanyVendorTable + ' CV on C.Id = CV.CompanyId inner join ' + @FrontendVendorTable + ' FV on CV.VendorId = FV.Id where FV.active=1 order by FV.VendorName' exec sp_executesql @Sqlend/* proc_GetFrontEndVendors 'sandbox'*/ Output:ID VendorName CompanyCode1 aaa A11 aaa A22 bbb B12 bbb B2But I want the output as:1 aaa A1,A22 bbb B1,B2 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|