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
 Help with simple insert

Author  Topic 

DEZDEF
Starting Member

1 Post

Posted - 2007-02-13 : 16:02:05
Hello everyone:

From the help files in sql 2000:

INSERT INTO archivetitles
(title_id, title, type, pub_id)
SELECT title_id, title, type, pub_id
FROM titles
WHERE (pub_id = '0766')


How would I modify this if the table archivetitles had columns:
titleid, title, newcolumn, type, pub_id
and I wanted the newcolumn value to be null, but I still wanted to select the values from titles?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-02-13 : 16:17:31
INSERT INTO archivetitles
(title_id, title, newcolumn, type, pub_id)
SELECT title_id, title, NULL, type, pub_id
FROM titles
WHERE (pub_id = '0766')

This seems like a homework question...


Tara Kizer
Go to Top of Page
   

- Advertisement -