SQLTeam.com | Weblogs | Forums

How to skip the row in a table,while inserting the data into the table when particular field is not null?

sql2012

#1

Hi Friends,

How to skip the row in a table,while inserting the data when particular column is not null? .
For Example
In Master table Column (Opendate) ,datatype is (Datetime) Null,
In Child Table Column (Opendate) ,datatype is (Datetime) Not Null,.

I have Loaded the date into Master tables since that column us Null,If any rows is Empty it will update as NULL in the table.
and Now when Loading same data from Master to Child table Since Not even single row have been loaded .
There are only 4 rows are Empty out 20 rows..
I need a solution to load these data and need to skip if any row is NULL.


#2

Not sure what you mean by

If any rows is Empty

But, iIf you add a WHERE clause:

WHERE col1 IS NOT NULL and col2 IS NOT NULL and ...etc

you will not see any rows where all the columns are null.


#3

Assuming all the fields are same between Master and Child you can use this

INSERT INTO Child
SELECT *
FROM Master
WHERE OpenDate IS NOT NULL