Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.
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?

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.