Cannot select more than 4096 columns in the SELECT statement error

  • 8 August 2023
  • 0 replies
  • 18 views

Userlevel 7
Badge

This is an SQL Server limitation, you can see more about that in the link below: Maximum capacity specifications for SQL Server - SQL Server | Microsoft Learn 

 

Even though you cannot select more than 4096 columns, you can still use a SELECT * FROM <tablename> query to get all the columns. The downside of this method is that the unwanted columns will get selected too. 

Another workaround, and the most commonly used for this issue is to create a custom view in your SQL Server Management Studio. You can create the custom view by selecting all the columns you want to use and after creating the custom view all you have to do is to execute the SELECT * FROM <CustomView> statement. 


This topic has been closed for comments