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 2005 Forums
 Transact-SQL (2005)
 insert statement error

Author  Topic 

rum23
Yak Posting Veteran

77 Posts

Posted - 2009-03-11 : 10:36:55

can somebody tell me what is wrong with the sql below? thanks much

INSERT INTO tblProjInspJumperDetails (ProjectID, JumperNo,JumperMeterNo, BeginRead, EndRead, JumperRemoval)
VALUES(SELECT ProjectID, 'Jumper 1', DEPJumperMeterNo,JumperMeterBegReading, JumperMeterEndReading,
D_JumperRemoval FROM tblProjects WHERE DEPJumperMeterNo IS NOT NULL)

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-11 : 10:39:36
Drop the VALUES keyword. That is only for inserting a single constant row.

INSERT INTO tblProjInspJumperDetails (ProjectID, JumperNo,JumperMeterNo, BeginRead, EndRead, JumperRemoval)
SELECT ProjectID, 'Jumper 1', DEPJumperMeterNo,JumperMeterBegReading, JumperMeterEndReading, D_JumperRemoval
FROM tblProjects
WHERE DEPJumperMeterNo IS NOT NULL



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

rum23
Yak Posting Veteran

77 Posts

Posted - 2009-03-11 : 10:40:43

Great! thanks. The response time in this forum is just amazing!
Go to Top of Page
   

- Advertisement -