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
 SQL Server Development (2000)
 Insert

Author  Topic 

vicki
Posting Yak Master

117 Posts

Posted - 2002-03-08 : 11:29:37
Hi,

if I just want to insert only last 2 columns from log table into phonebook table then how can I do?

insert into phonebook(Department, FreqNumber, Facility, LogSize_MB, LogSpaceUsed)
select LogSize_MB, LogSpaceUsed
from log

But it dind't work and I know why because The select list for the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns.HOWERVER, if I really want to take all the records from last columns in table LOG and insertino phonebook table then how can I do?
Thanks


robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-03-08 : 11:48:10
Take the excess columns out of the INSERT column list:

insert into phonebook(LogSize_MB, LogSpaceUsed)
select LogSize_MB, LogSpaceUsed
from log




Go to Top of Page
   

- Advertisement -