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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dropping columns

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-04-13 : 07:26:47
Justin writes "Hi there,

I am new to SQL Server 2000 and have very much been thrown into the deepend. I am developing an asp.net application that queries an SQL db.

Basically the problem I have come across is this. I want to display SOME information from a table. What I am doing is creating a temp table. I now want to drop columns that have no values entered.

ie: If there are columns called user Text#1, Text#2, Text#3
if text#1 has no values, ie they are all null or blank I want to drop that column, but if it had any values I want to display that column.

The short of it is the user will not see a blank column with no data all the way down! I have searched the web and found examples of how to do this using Oracle.

Can you help?

Thanks for your help,

Justin."

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-04-13 : 08:38:30

If exists(select * from table where text1 is not null)
.....Drop the column

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2005-04-13 : 11:08:35
quote:
Originally posted by madhivanan


If exists(select * from table where text1 is not null)
.....Drop the column

Madhivanan

Failing to plan is Planning to fail



Shouldn't that be

If not exists(select * from table where text1 is not null)
.....Drop the column




-------
Moo. :)
Go to Top of Page
   

- Advertisement -