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
 General SQL Server Forums
 New to SQL Server Programming
 Invalid column name in Insert with Select ...?

Author  Topic 

phrankbooth
Posting Yak Master

162 Posts

Posted - 2010-01-22 : 16:14:02
I believe my syntax is correct here, and when I run just the select statement it works just fine, however, when I run both together, I get, "Invalid column name 'Continent'"

insert into dbo.tblListItem (ListID, ListItem, ParentID) values (6, Continent, null)
SELECT distinct Continent FROM Territories$

Any ideas?

Thanks!

--PhB

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-01-22 : 16:24:39
Are you trying to insert the continents from the territiories$ table into tblListItem, along with a 6 and a NULL?

if so...

INSERT INTO dbo.tblListItem (ListID, ListItem)
SELECT distinct 6, Continent FROM Territories$
Go to Top of Page

phrankbooth
Posting Yak Master

162 Posts

Posted - 2010-01-22 : 16:26:46
Perfect!!

Thank you!!

--PhB
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-01-22 : 17:34:48
You're welcome
Go to Top of Page
   

- Advertisement -