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
 Transact-SQL (2000)
 Error in Insert statement

Author  Topic 

Johnyalm
Starting Member

49 Posts

Posted - 2003-10-14 : 06:22:57
I get this error

Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'SELECT'.

for this statement

INSERT INTO tblGILSEARCH (id_actors)
VALUES
SELECT DISTINCT id_actors FROM tblFORMDATA WHERE tblFORMDATA.FormID = '105115662'

Please help me

Johny


www.mirrorgate.com

OMB
Yak Posting Veteran

88 Posts

Posted - 2003-10-14 : 07:15:41
Johny

Just get rid of the Values condition.

i.e.
INSERT INTO tblGILSEARCH (id_actors)
SELECT DISTINCT id_actors FROM tblFORMDATA WHERE tblFORMDATA.FormID = '105115662'

OMB

OMB
Go to Top of Page

Johnyalm
Starting Member

49 Posts

Posted - 2003-10-14 : 07:19:12
Thanx!

Next problem I have is an UPDATE statement

I get an error for this statement as well:

UPDATE tblGILSEARCH SET stadsdel =

SELECT DISTINCT Result AS stadsdel
FROM tblFORMDATA INNER JOIN
tblGILSEARCH ON tblFORMDATA.id_actors = tblGILSEARCH.id_actors
WHERE dbo.tblFORMDATA.Ctrlname = 'stadsdel' AND dbo.tblFORMDATA.FormID = '105115662'

www.mirrorgate.com
Go to Top of Page

OMB
Yak Posting Veteran

88 Posts

Posted - 2003-10-14 : 07:31:44
Are you trying to update the whole table or just one row, this looks like your updating the whole table.
Go to Top of Page

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2003-10-14 : 08:56:08
Here is an update on your two tables be sure it delivers the results you desire before executing.

Run just select in QA first:
UPDATE a SET a.Stadsdel = b.result
--- SELECT a.id_actors, a.Stadsdel, b.result
FROM tblGILSEARCH a INNER JOIN tblFORMDATA b
ON a.id_actors = b.id_actors
WHERE b.Ctrlname = 'stadsdel' and b.FormID = '105115662'
Go to Top of Page
   

- Advertisement -