473,473 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

script to remove nulls from DB?

Hi all.

I've been tasked with "speeding up" a mid-sized production system. It
is riddled with nulls... "IsNull" all over the procs, etc.

Is it worth it to get rid of the nulls and not allow them in the
columns anymore?

If so, how to go about removing the nulls with a script?

Thanks so much,

Steve in Norcal
Jul 20 '05 #1
2 2336

"Steve Walker" <sw*****@ainet.com> wrote in message
news:bd**************************@posting.google.c om...
Hi all.

I've been tasked with "speeding up" a mid-sized production system. It
is riddled with nulls... "IsNull" all over the procs, etc.

Is it worth it to get rid of the nulls and not allow them in the
columns anymore?

If so, how to go about removing the nulls with a script?

Thanks so much,

Steve in Norcal


You need to consider the data model first - if it has a good reason for
requiring certain columns to be NULLable, then you should leave them.
Although in general, if you have a large number of NULLable columns, then
your data model probably needs to be reviewed, as it suggests you may have
issues such as incomplete data, or denormalized tables.

To make a column NOT NULL from a script, you can use ALTER TABLE:

ALTER TABLE dbo.MyTable
ALTER COLUMN SomeColumn INT NOT NULL

Simon
Jul 20 '05 #2
[posted and mailed, please reply in news]

Steve Walker (sw*****@ainet.com) writes:
I've been tasked with "speeding up" a mid-sized production system. It
is riddled with nulls... "IsNull" all over the procs, etc.

Is it worth it to get rid of the nulls and not allow them in the
columns anymore?


Probably not. As Simon said, the columns are likely to be nullable for
a reason.

Then again, I would not be surprised if some columns are nullable only
because of lax design.

It's better to track down slow-running queries, and see how you can
improve them, either by rewriting or better indexing.

Lots of isnull does not have to be bad, but it can be. Take these
two examples:

SELECT col1, col2, col3
FROM tbl
WHERE thiscol = isnull(@par, ' ')

SELECT col1, col2, col3
FROM tbl
WHERE isnull(thiscol, ' ') = isnull(@par, ' ')

The first is OK, and the cost of isnull is likely to be minimal. The
second, however, is potentially bad. This is because, if there is an
index on thiscol, then SQL Server can not seek this index to find
the data. As soon as a column is embedded into an expression, it
is disqualified from index seeks. This is because the index is
organized after the values of the column, not the values of the
expression.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AzGhanv/. | last post by:
Hi, I m searching for some Script / Function ... to find difference in data b/w 2 similar tables (exactly same fields structure) in sql 2000. plz update me asap ! thanks in advance !
0
by: Rhino | last post by:
I am working with SQL Functions in DB2 for Windows/Linux/UNIX (V8.2.1) and am having a problem setting input parameters for SQL Functions to null in the Development Center. My simple function,...
1
by: PST | last post by:
Here's a problem I'm trying to deal with: I'm working on a Frontpage 2000 website for a boat handicapping system, built in Access 97. What I'm trying to accomplish is: The user enters a...
0
by: LunchBox | last post by:
I'm getting null values in a DataSet which is pulling its data from a web service. The nulls are creating 'System.Data.ConstraintException' in the fields that do not allow columns. I've tried...
1
by: buc | last post by:
I have created a byte array (1000 in size) to recv a network packet. I recv the packet, which varies in size, and need to put the packet in a string; so I can append another string after the packet...
5
by: Russell Warren | last post by:
I've got a case where I'm seeing text files that are either all null characters, or are trailed with nulls due to interrupted file access resulting from an electrical power interruption on the...
7
by: active | last post by:
I want to remove all non-printable characters - including nulls. I could extend the following by adding as many printable characters as I can think of. But I wonder if there isn't something...
6
by: Cliff72 | last post by:
I need to fill in the nulls in the batch field the value from the record immediately preceding the null one ie replace the nulls with the preceding value until I hit a record with a value in...
26
by: Brad | last post by:
I'm writing a function to remove certain characters from strings. For example, I often get strings with commas... they look like this: "12,384" I'd like to take that string, remove the comma...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.