How to set one of the insert value as a select ?

Hi,  I'm using sql 2005 express.
My query is getting an syntax error .  As you can see, I want to get the personID value from a select statement.  How can I do this?  Thanks.
--
INSERT INTO [MedDb].[dbo].[PersonPosition]
           ([personID]
           ,[Position_ID]
           ,[Position_Title]
           ,[Position_Bio]
           ,[Position_Narrative]
           ,[Position_Narrative_short]
           ,[web_visible]
           ,[PhotoId]
           ,[PositionTypeId]
           ,[DepartmentId])
     VALUES
           ((select personID from dbo.contact pp
where pp.personID not in (select personID from dbo.PersonPosition))
           ,0
           ,null
           ,null
           ,null
           ,null
           ,1
           ,-1
           ,-1
           ,-1)

Open in new window

lapuccaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SharathData EngineerCommented:
try like this.
INSERT INTO [MedDb].[dbo].[PersonPosition] 
           ([personID], 
            [Position_ID], 
            [Position_Title], 
            [Position_Bio], 
            [Position_Narrative], 
            [Position_Narrative_short], 
            [web_visible], 
            [PhotoId], 
            [PositionTypeId], 
            [DepartmentId]) 
SELECT personID, 
       0, 
       NULL, 
       NULL, 
       NULL, 
       NULL, 
       1, 
       -1, 
       -1, 
       -1 
  FROM dbo.contact pp 
 WHERE pp.personID NOT IN (SELECT personID 
                             FROM dbo.PersonPosition)

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SharathData EngineerCommented:
If you want to stick to your query, you can use TOP clause.
--
INSERT INTO [MedDb].[dbo].[PersonPosition]
           ([personID]
           ,[Position_ID]
           ,[Position_Title]
           ,[Position_Bio]
           ,[Position_Narrative]
           ,[Position_Narrative_short]
           ,[web_visible]
           ,[PhotoId]
           ,[PositionTypeId]
           ,[DepartmentId])
     VALUES
           ((select top 1 personID from dbo.contact pp
where pp.personID not in (select personID from dbo.PersonPosition))
           ,0
           ,null
           ,null
           ,null
           ,null
           ,1
           ,-1
           ,-1
           ,-1)

Open in new window

SharathData EngineerCommented:
or in my query, you can use TOP 1 if you just want one record to be inserted.
INSERT INTO [MedDb].[dbo].[PersonPosition] 
           ([personID], 
            [Position_ID], 
            [Position_Title], 
            [Position_Bio], 
            [Position_Narrative], 
            [Position_Narrative_short], 
            [web_visible], 
            [PhotoId], 
            [PositionTypeId], 
            [DepartmentId]) 
SELECT TOP 1 personID, 
       0, 
       NULL, 
       NULL, 
       NULL, 
       NULL, 
       1, 
       -1, 
       -1, 
       -1 
  FROM dbo.contact pp 
 WHERE pp.personID NOT IN (SELECT personID 
                             FROM dbo.PersonPosition)

Open in new window

lapuccaAuthor Commented:
I want insert all from the select result but do thank you for including other possibilities.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.