How to bind to a column for a where clause, no join between tables
$10-30 USD
Completed
Posted almost 7 years ago
$10-30 USD
Paid on delivery
I need to join to get the phone number from the PEOPLECHANGES table. When I try to filter I get the error The multi-part identifier "dbo.PEOPLECHANGES.People_ID" could not be bound. There's no join between the tables so I can't alias it. How do I bind to it?
USE Bridge
declare @NextIdentityID table (PersonId int, People_ID int);
INSERT INTO [dbo].[PeopleTest]
([People_ID]
,[text])
output Inserted.People_ID, [login to view URL] into @NextIdentityID(People_ID, PersonId)
SELECT
PEOPLE_ID,'row1' --PEOPLE_ID, 000092437
FROM PeopleChanges
WHERE PEOPLE_ID = '000092435' --just insert our single test row
select * from @NextIdentityID
INSERT INTO [dbo].[Phone] --Msg 8152, Level 16, State 4, Line 14, String or binary data would be truncated.
([PersonPhoneId] --000092437
,[PersonId] --PersonId int 361
,[PhoneType] --'Home Row 1'
,[Number]) --(927)968-7544, NULL, (214)709-3001
/*
@NextIdentityID
PersonId People_ID
388 92435
PEOPLECHANGES
PEOPLE_ID
000092437
*/
--method if PersonPhoneID not equal PEOPLE_ID, no join, use where PC.PEOPLE_ID = Idn.PEOPLE_ID
select PEOPLE_ID, [login to view URL],'Home Row 1', REPLACE(REPLACE(REPLACE(REPLACE(Phone1,'(',''),' ',''),'-',''),')','') from @NextIdentityID Idn WHERE Idn.PEOPLE_ID = CONVERT(INT, dbo.PEOPLECHANGES.People_ID) --PEOPLE_ID 000092437, PersonID 92437 one is varchar, one is integer
--The multi-part identifier "dbo.PEOPLECHANGES.People_ID" could not be bound.
Msg 207, Level 16, State 1, Line 31
I can select from PEOPLECHANGES and get the following resultes
SELECT PEOPLE_ID FROM PEOPLECHANGES
WHERE PEOPLE_ID = '000092437'
Results
PEOPLE_ID
000092437
Dear Sir/Madam,
Hope you are doing well.
As a database administrator and developer have done tasks like this to understand and recommend on SQL's. Could we please have a chat and start the work?
Thanks,
Pratik
Greetings.
I am MSSQL dba. Having 13 years of IT experience. 5 years as dedicated dba and 8 years as .NET/SQL developer.
Please ping me to discuss more.
Looking to work with you to solve this.
Thanks & Regards,
Milind