Retrieving Empty Records in MS-SQL

21.03.2025
497
Retrieving Empty Records in MS-SQL

We will talk about the null record error, which is a common problem when pulling sequential data from MS SQL database with the help of while loop. The first precaution that can be taken against the possibility of null values in one or more of the fields in the record line will be not to turn on the “Allow Null” feature for the fields you define when designing your database.

Sql Null Expression

However, if there is a possibility that a null record can be entered, for example, the second name digit is not valid for everyone. Not everyone may have a second name and there is a high probability of a null value, in this case, how can we develop a solution.

In this case, the IS NOT NULL statement is used at the end of the sql clause when SELECT data. If we explain with an example:

SELECT adi, ikinci_adi, soyadi, cinsiyeti FROM kimlik_tablosu WHERE ikinci_adi IS NOT NULL;
SQL

can be written as. This clause will display the list of records whose second_name is different from null, or in other words only the list of people with second_name. It can also be used with different variations:

SELECT adi,ikinci_adi,soyadi,cinsiyeti FROM kimlik_tablosu WHERE ikinci_adi IS NOT NULL AND cinsiyeti='E' ORDER BY adi DESC;
SQL

If we want to list the records with empty fields, we will need to use the IS NULL parameter.

MAKE A COMMENT
COMMENTS - 0 COMMENTS

No comments yet.

Bu web sitesi, bilgisayarınıza bilgi depolamak amacıyla bazı tanımlama bilgilerini kullanabilir.
Bu bilgilerin bir kısmı sitenin çalışmasında esas rolü üstlenirken bir kısmı ise kullanıcı deneyimlerinin iyileştirilmesine ve geliştirilmesine yardımcı olur.
Sitemize ilk girişinizde vermiş olduğunuz çerez onayı ile bu tanımlama bilgilerinin yerleştirilmesine izin vermiş olursunuz.
Çerez bilgilerinizi güncellemek için ekranın sol alt köşesinde bulunan mavi kurabiye logosuna tıklamanız yeterli. Kişisel Verilerin Korunması,
Gizlilik Politikası ve Çerez (Cookie) Kullanımı İlkeleri hakkında detaylı bilgi için KVKK&GDPR sayfamızı inceleyiniz.
| omersahin.com.tr |
Copyright | 2007-2025