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
 Transact-SQL (2000)
 Null or ???

Author  Topic 

karuna
Aged Yak Warrior

582 Posts

Posted - 2002-02-08 : 03:29:03
I have a table with the following structure....


Column Name Type length Nullable

recruiter_id decimal 9 no
salutation nvarchar 20 yes
fname nvarchar 150 no
lastname nvarchar 150 yes
email nvarchar 300 no
password nvarchar 20 no
designation nvarchar 100 no
enabled bit 1 no
hold bit 1 no
dateofregistration smalldatetime 4 no

I designed this table in the Enterprise Manager.Apart from Salutaion and Lastname no other columns can allow Null.In the above table apart from enabled and hold all other fields has to be filled im by the user in the front end.But when I went through the table my after some trial registrations etc...I found that in 2 records the email column was empty...I didnt got any error when I registered...I filled up the form,but that value didnt got inserted in that column that too for 1 or 2 records...Any Idea how that would had happend???...Now what I like to know is, I dont want to have a floating user like this with incomplete info, Is there anyway to check whether all mandatory columns in the table has values.if those columns have an empty string or null value then the insert should be rolled back....


In very simple way All I want to know is....

Is it possible to check few fields in a record,whether its having a null value or empty string....


Karunakaran

Don't wait for things to happen,Make them to happen...

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-02-08 : 04:06:57
Hi

You have two places where you can check this. The first is in the interface layer, I.E. VB or ASP. You can either validate the data before submitting to the table (preferred) or convert blank strings to NULL so that the insert fails.

The second place is at the database. You could have an Insert trigger on the table to check for empty strings.

For this, I would tend to put validation at the interface level. That way you check things like valid email addresses before the record is inserted.

Hope that helps

Damian
Go to Top of Page

karuna
Aged Yak Warrior

582 Posts

Posted - 2002-02-08 : 04:16:43
Yes..I do check at the interface level...Unless the form is complete in all the ways the user cannot submit the form...SO the data is lost some where in middle...Its not happening for all users..so far 2 in the total of 200...Since its validated at the interface level there would be the data from the interface to the sql...Since the columns cannot allow null,i believe it will accept empty strings,so is there any way to validate again at the SQL level by using any methods or do i have to crosscheck the values got inserted in the tables.....

Karunakaran

Don't wait for things to happen,Make them to happen...
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-02-08 : 05:44:17
Well if you are checking at the interface level, but invalid data is still coming through, then it would appear you have a bug in your interface code.

I would try to isolate and fix the bug rather than write a whole bunch more code to catch the first bug.

Remember, the less code you have to write, the less bugs can slip in. Fix your existing code first.

Damian
Go to Top of Page
   

- Advertisement -