how to print result separated with comma
DECLARE @col nvarchar(MAX);
select ColumnName into #temp from Mnblabla
--SELECT TOP 5 AcquirerId INTO #pdxterminals FROM PDXTerminals
SELECT @col = COALESCE(@col + ',', '') + ColumnName
FROM #temp
DROP TABLE #temp
PRINT @col
------------------------------------------manasha logic-------------------------------------------
declare
@x varchar(max),
@modcolnames varchar (max),
@modcolnames1 varchar (max),
@y varchar(max)=1
drop table #temp
SELECT *, ROW_NUMBER() OVER(ORDER BY ColumnName) AS Row_Number INTO #temp
FROM MNSuperAdminMakerChecker where Code=60
set @x=(select Count(*) from MNSuperAdminMakerChecker where Code=60)
while(@y<=@x)
BEGIN
SET @modcolnames = (SELECT ColumnName from #temp WHERE Row_Number = @y)
SET @y = @y +1
SET @modcolnames1 = CONCAT(@modcolnames1 ,',',@modcolnames)
END
SELECT @modcolnames1 as 'Modified Column'
Comments
Post a Comment