Link to home
Start Free TrialLog in
Avatar of brgdotnet
brgdotnetFlag for United States of America

asked on

How to just insert one column value into a multi column temp table

Hello Experts. I have a temp table, and initially I just want to insert into it, one column value "EntityId". So after the insert statement all EntityId column fields will be populated based upon my insert statement that involves a sub query.

 My insert statetement is failing though. I have tried changing the syntax of the insert statement, and my syntax is incorrect. Can someone tell me how to change the INSERT statement below, so that it will insert the #TempTable with the EntityId values?

CREATE TABLE #TempTable (EntityId varchar(64),
                              NameOfEntry varchar(150),
                              AgeId varchar(10))

INSERT INTO #TempTable SELECT EntityId from Customers where EntityId NOT IN (Select EntityId from OldCustomers)
ASKER CERTIFIED SOLUTION
Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brgdotnet

ASKER

Thank you Jim. I could swear I tried that before posting the question, and it was not working. I was probably just really tired. Thanks so much. I liked your solution the best. HauMinChin, also thank you very much.