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)
 Only returning columns that aren't null

Author  Topic 

tadi
Starting Member

3 Posts

Posted - 2001-05-18 : 11:38:12
Hi,

I'm in the process of doing a big data conversion from a clients old (horrible) database to a new, normalized structure. In order to do the conversion, I need to load all of the old data into a small visual basic application i wrote to handle the transformation.

Here's the problem. The main table that I have to grab data from has 24000+ records, each with 400+ columns. Don't ask why its like that, just know that I'm trying to fix it :) So, my vb app needs to load all of that data into collection classes in order to be able to manipulate it. The problem is, for each record, I have to loop through all 400 of those columns to determine if there is any data in the column that I need to store. I'd rather only return columns in the recordset that don't have null values. Each record only has 10-20 of the columns populated with data, so this would bring my iteration count way down (24000*400 = 9.6 million iterations, 24000*20 = 480k iterations). Is there anyway to build a sql statement to do this?

-----
Jason Fox

   

- Advertisement -