We can use BCP utility to get the data of the table (queryout option). The contents of the file will have character field (with varchar(MAX) / nvarchar(MAX)) with all...
The approach mentioned using CTE does not work for string (@array) which has more than 100 numbers. (e.g '1,2,3,4,5,....,101'). SQL Server returns following error message -
Using this method, the SELECT query is executed 'n' number of times, where n is total number of records in the table. I dont think this is optimized solution....
The working of pivot depends upon the columns we specify in the select list. The pivot has one column on which aggregate function is applied (like sum(),count(), etc), the second...