473,385 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Sql Server 2000: How To Handle Null In Select Statement

Hi all,

In my table there is a varchar column having NULL and string names.

while i am running select on this table the NULL values are not returned. the statement returns only non null values. my query is

SELECT EMP_ID, AGE FROM EMPLOYEE WHERE EMP_NAME <> 'BABU'

in my table there is records with null values. but it retuns only non null values.

thanks in advance,

dhana.
Mar 15 '08 #1
5 2339
davidson1
144 100+
check like this...

if isdbnull(emp_id)
{
Response.write("Null Values")
}
else
{
Response.write("Not Null Values")
}
Mar 16 '08 #2
ck9663
2,878 Expert 2GB
Hi all,

In my table there is a varchar column having NULL and string names.

while i am running select on this table the NULL values are not returned. the statement returns only non null values. my query is

SELECT EMP_ID, AGE FROM EMPLOYEE WHERE EMP_NAME <> 'BABU'

in my table there is records with null values. but it retuns only non null values.

thanks in advance,

dhana.

try:

SELECT EMP_ID, AGE FROM EMPLOYEE WHERE EMP_NAME <> 'BABU' or EMP_NAME is NULL


-- CK
Mar 17 '08 #3
There is one exception with %. Not Even the clause where name like '%' will match a row with the value NULL.

create table stu(name varchar(10))
insert into stu values('sona')
insert into stu values('soni')
insert into stu values('sonia')
insert into stu values(NULL)
select * from stu
select * from stu where name like '%'

RESULT--

sona
soni
sonia
Mar 17 '08 #4
Hey Ck,the answer given by you was not working, SEE the EXAMPLE BELOW--
create table student(roll int,marks int)
insert into student values(1,10)
insert into student values(2,10)
insert into student values(3,20)
insert into student values(4,NULL)
select * from student
select roll from student where marks <>20 AND marks is NULL

RESULT--BLANK
Mar 17 '08 #5
deric
92
Hey Ck,the answer given by you was not working, SEE the EXAMPLE BELOW--
create table student(roll int,marks int)
insert into student values(1,10)
insert into student values(2,10)
insert into student values(3,20)
insert into student values(4,NULL)
select * from student
select roll from student where marks <>20 AND marks is NULL

RESULT--BLANK

CK's example is correct. You should have used the "OR" operator, instead of "AND".
Mar 17 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000...
19
by: Thue Tuxen Sørensen | last post by:
Hi everybody ! I´m maintaining a large intranet (approx 10000 concurrent users) running on one IIS box and one DB box with sqlserver 2000. Currently there is 2,5 GB Ram, 1 1400 mhz cpu and 2...
13
by: Jeager | last post by:
Why is it, Microsoft manage to write operating systems and office applications with every bell and whistle facility known to man. Yet, even after years and years of development they still cannot...
1
by: Stefan V. | last post by:
Hello! I am trying to convert a query written for SQL Server 2000 database tables, to a MS Access query. Here is what I have in SQL Server: SELECT t2.*, CASE WHEN t2.QType = '3' THEN...
2
by: Charles Wilt | last post by:
I have a IBM iSeries (aka AS-400) running v5r3 of OS/400 that I access via a linked server from SQL Server 2000. The following select works fine: select * from...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
0
by: padhuwork | last post by:
Hi, I want to create a Windows DLL using VC++ 6.0 which connects to SQL Server. After establishing the connection, I want to retrieve records from table (query) and out put the recordset to a...
8
by: rbg | last post by:
I did use query plans to find out more. ( Please see the thread BELOW) I have a question on this, if someone can help me with that it will be great. In my SQL query that selects data from table,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.