0
insert into [ULGP_CARES TEST].[dbo].[person](date_of_birth)

select [Dtest].[dbo].[ContactBase].[BirthDate] 
from [Dtest].[dbo].[ContactBase]
where
[Dtest].[dbo].[ContactBase].[FirstName]=[ULGP_CARES TEST].[dbo].[person].[first_name]

and
[Dtest].[dbo].[ContactBase].[MiddleName]=[ULGP_CARES TEST].[dbo].[person].  [middle_name] 
and
[Dtest].[dbo].[ContactBase].[LastName]=[ULGP_CARES TEST].[dbo].[person].[last_name]

while trying to run the above query i am getting the following error "Msg 4104, Level 16, State 1, Line 6 The multi-part identifier "ULGP_CARES TEST.dbo.person.first_name" could not be bound. Msg 4104, Level 16, State 1, Line 9 The multi-part identifier "ULGP_CARES TEST.dbo.person.middle_name" could not be bound. Msg 4104, Level 16, State 1, Line 11 The multi-part identifier "ULGP_CARES TEST.dbo.person.last_name" could not be bound."

how to solve this?

user87
  • 1

1 Answers1

1

Try this:

insert into [ULGP_CARES TEST].[dbo].[person](date_of_birth)
select [Dtest].[dbo].[ContactBase].[BirthDate] 
from [Dtest].[dbo].[ContactBase]
join [ULGP_CARES TEST].[dbo].[person] 
on [ContactBase].[FirstName]=[person].[first_name]
and [ContactBase].[MiddleName]=[person].[middle_name] 
and [ContactBase].[LastName]=[person].[last_name]

Without including the person table in the JOIN clause, SQL doesn't realize that it exists.

If that doesn't help out, you should also check the following:

Are you sure that the database named "ULGP_CARES TEST" exists? Perhaps it is spelled or capitalized differently, or that the space character is actually an underscore or vice versa. It's unusual to have an underscore and a space in the same database name.

Are you sure that the table named "person" exists in the database named "ULGP_CARES TEST"? Perhaps it is spelled or capitalized differently, or perhaps it is not part of the "dbo" schema.

Are you sure that the columns "first_name", "middle_name" and "last_name" exist in the table named "person" in the database named "ULGP_CARES TEST"? Perhaps it is spelled or capitalized differently.

Darin Strait
  • 2,012
  • 12
  • 6