Monday, February 20, 2012

Move data from one table to another

Trying to copy data from table one (name) to table two (n_system).
Field name.co_id to n_system.ultimate_id where name.id = n_system.id.
insert n_system (id, ultimate_id)
SELECT id, co_id FROM name
where name.id = n_system.id
Error message
Server: Msg 107, Level 16, State 3, Line 1
The column prefix 'n_system' does not match with a table name or alias
name used in the query.Use this format
insert into tabletwo select field1, field2 from tableone
Ben Nevarez, MCDBA, OCP
Database Administrator
"jp" wrote:
> Trying to copy data from table one (name) to table two (n_system).
> Field name.co_id to n_system.ultimate_id where name.id = n_system.id.
> insert n_system (id, ultimate_id)
> SELECT id, co_id FROM name
> where name.id = n_system.id
> Error message
> Server: Msg 107, Level 16, State 3, Line 1
> The column prefix 'n_system' does not match with a table name or alias
> name used in the query.
>|||Also, the problem is the where clause. You can not use n_system there in
that context. You need specify something, for example a constant
where name.id = 123
Ben Nevarez, MCDBA, OCP
Database Administrator
"Ben Nevarez" wrote:
> Use this format
> insert into tabletwo select field1, field2 from tableone
> Ben Nevarez, MCDBA, OCP
> Database Administrator
>
> "jp" wrote:
> > Trying to copy data from table one (name) to table two (n_system).
> > Field name.co_id to n_system.ultimate_id where name.id = n_system.id.
> >
> > insert n_system (id, ultimate_id)
> > SELECT id, co_id FROM name
> > where name.id = n_system.id
> >
> > Error message
> > Server: Msg 107, Level 16, State 3, Line 1
> > The column prefix 'n_system' does not match with a table name or alias
> > name used in the query.
> >
> >

No comments:

Post a Comment