Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 4000+ columns

Author  Topic 

latent_ken
Starting Member

10 Posts

Posted - 2011-09-12 : 10:57:41
Hi I have 8 tables that i need to combine into one. I wanted to use a view for this but the problem is that my select statement has over 1024 columns. I would just use a select * statement but then i have the same user id column repeated. Is there a way that i could remove the columm after the select * ?

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-09-12 : 11:02:12
You'd have to list each column explicitly. You're also limited to 4096 columns per SELECT statement so you don't have much margin.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-09-12 : 11:25:17
[code]
SELECT CHAR(9) + '[' + TABLE_NAME + '].[' + COLUMN_NAME + '] AS [' + COLUMN_NAME + '],'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME IN ('MyTable1', 'MyTable2')
ORDER BY TABLE_NAME, ORDINAL_POSITION
[/code]
will get you a list you could hack about
Go to Top of Page

latent_ken
Starting Member

10 Posts

Posted - 2011-09-12 : 12:04:27
what does the char(9) do exactly ?
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-09-12 : 12:31:02
TAB - which will make your code look neat
Go to Top of Page
   

- Advertisement -