Sql-server – able to query for more than 1024 columns but I can not make a view of the same query

sql serversql-server-2012view

My boss is requesting a view with greater than 1024 columns where in he will only select a few columns he wants when he queries the view so that the actual returned columns are less than 1024. Why am I able to query for greater than 1024 columns but I can not save this very same query as a view?

I am using SQL Server 2012 Enterprise

Best Answer

A View is not a Result Set. A View is an object that needs a clear definition. A Result Set, on the other hand, has a bit more freedom. For example, you can have both missing column names and/or duplicate column names in a Result Set. But Tables and Views cannot allow for either since you would not be able to SELECT such columns (there would be no way to clearly specify which columns you were referring to).

Run the following, for example:

SELECT 1, 2 AS [t], 3 AS [t];