Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Max number of Columns allowed in SQL Server 2008 View?

More of a curious question I can't seem to quickly find an definite answer to.

In SQL Server 2008 is there a max limitation on the number of columns that are allowed in a view? From the MSDN article (below) I see that there is a limit of 4096 Columns per Select statement. Would this then be applied to a View?

Example:

CREATE VIEW [dbo].[TestView]
AS
SELECT     Column1, Column2 FROM dbo.SomeTableName

Would I be limited to 4096 columns in this view?

http://msdn.microsoft.com/en-us/library/ms143432.aspx

like image 764
sugarcrum Avatar asked Oct 07 '09 20:10

sugarcrum


2 Answers

By default of finding an authoritative source, I figured I'd try...

It appears that the limit is 1024 columns, that is the case in SQLServer 9.0 (both 'Express' and Enterprise versions).

    The error message is:
    Msg 4505, Level 16, State 1, Procedure wvTest, Line 3
    CREATE VIEW failed because column 'Yo1' in view 'vwTest'
                       exceeds the maximum of 1024 columns.
like image 176
mjv Avatar answered Sep 21 '22 20:09

mjv


Here is Microsoft link for complete details....

http://msdn.microsoft.com/en-us/library/ms143432.aspx

According to this Microsoft...

Columns per nonwide table  | 1,024 
Columns per wide table     | 30,000
like image 20
Zeb-ur-Rehman Avatar answered Sep 19 '22 20:09

Zeb-ur-Rehman