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
 General SQL Server Forums
 New to SQL Server Programming
 Adding a restriction to an Insert

Author  Topic 

gemispence
Yak Posting Veteran

71 Posts

Posted - 2006-02-16 : 17:57:28
I'm inserting rows from one table to another and trying to figure out how to not allow nulls from one field. ie - the feeder table can have nulls, but when I insert into the other table, I don't want the records that have NULLS in one field to insert. I hope that's clear.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-16 : 18:00:38
INSERT INTO Table1 (Column1, Column2, Column3)
SELECT Column1, Column2, Column3
FROM Table2
WHERE Column1 IS NOT NULL

Tara Kizer
aka tduggan
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-16 : 18:02:49
change the column to NOT NULL
use ALTER TABLE to do this

----------------------------------
'KH'

Time is always against us
Go to Top of Page

gemispence
Yak Posting Veteran

71 Posts

Posted - 2006-02-16 : 18:12:46
tkizer - you are truly my Almighty SQL Goddess. What can i say.
Go to Top of Page
   

- Advertisement -