why do you want to do it in the back end? It will be slower and harder to debug. There are no good ways. If the result set is a static result (you always know what the column headers will be then this probably would work)./*Hi ExpertsSuppose We have Table Str. likeRollNo Name1 A2 B3 C4 Di want the output likeRollNo Name1 ARollNo Name2 BRollNo Name3 CRollNo Name4 D*/DECLARE @foo TABLE ( [RollNo] INT , [Name] CHAR(1) PRIMARY KEY ([RollNo]) )INSERT @foo ([rollNo], [Name]) SELECT 1, 'A'UNION SELECT 2, 'B'UNION SELECT 3, 'C'UNION SELECT 4, 'D'SELECT [rollNo] , [name]FROM ( SELECT ROW_NUMBER() OVER (ORDER BY [RollNo]) AS [rowPos] , 1 AS [Result] , CAST([RollNo] AS VARCHAR(50)) AS [rollNo] , CAST([Name] AS VARCHAR(50)) AS [Name] FROM @foo f UNION ALL SELECT [rowPos] , 0 AS [Result] , 'rollNo' AS [rollNo] , 'Name' AS [Name] FROM ( SELECT ROW_NUMBER() OVER (ORDER BY [RollNo]) AS [rowPos] , CAST([RollNo] AS VARCHAR(50)) AS [rollNo] , CAST([Name] AS VARCHAR(50)) AS [Name] FROM @foo ) f WHERE f.[rowPos] > 1 ) resORDER BY res.[rowPos] , res.[Result]
But look how complicated that is! You lose any type information (you have to cast everything to varchars. Do it in the app -- this is stupid in the database.Results:rollNo name------ ----1 ArollNo Name2 BrollNo Name3 CrollNo Name4 D
Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION