February 10, 2020 at 12:19 pm
Hi
is there a way to identify empty columns.
I'm going through a new database right now and dropping columns that have never been used.
I've been generating SQL statements to get the max length value of each column and identifying columns that return NULL
If there is an easier way to do this I'd appreciate it.
Thanks,
Eamon
February 10, 2020 at 1:24 pm
I'm not aware of any way of doing this.
Strong suggestion, have a copy of your database in source control so that you can easily restore columns after you find out that they're somehow in use, but NULL when you query them.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
February 10, 2020 at 3:13 pm
Hi
is there a way to identify empty columns.
I'm going through a new database right now and dropping columns that have never been used.
I've been generating SQL statements to get the max length value of each column and identifying columns that return NULL
If there is an easier way to do this I'd appreciate it.
Thanks,
Eamon
I admire your tenacity but dropping even truly empty columns with great prejudice is a recipe for disaster. You don't know how the front end is setup and you could be breaking major amounts of front end and other code. Empty columns <> Unused columns.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 10, 2020 at 3:39 pm
Hi,
there isn't a front and end the columns dropped have never been used. It was originally put together with too many columns and lots of good intentions.
I do understand your comments and thanks for this. I'm just tidying up and very loosely built system.
Thanks
February 10, 2020 at 10:04 pm
To add to what Grant said, you might also want to look out for constraints, triggers, and references on those empty columns..
Please post DDL and follow ANSI/ISO standards when asking for help.
February 10, 2020 at 10:30 pm
...and every report in your system that your team or any other reporting team has built, to see if they are using those NULL columns. Or, as previously mentioned, blow them away but keep a copy you can restore with them still in there, so that if someone yells you can fix it.
-------------------------------------------------------------------------------------------------------------------------------------
Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses
February 11, 2020 at 12:13 pm
Also beware of any queries, views, procedures or reports that use "SELECT * FROM ..." one of these tables you propose to change.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply