My Assistant
![]() ![]() |
|
|
Feb 2 2012, 01:48 PM
Post
#1
|
|
|
UtterAccess Addict Posts: 247 |
I am trying to insert the column "Judicial_Comments" from a table called "Judicial_Comments" into Column "Judicial_Comments" in a table called "Loan_Info_local". The part that is giving me the error is in the WHERE clause
The error I'm getting: "Msg 4104, Level 16, State 1, Line 6 The multi-part identifier "dbo.Loan_Info_local.TS" could not be bound." CODE: USE ClientDB_MASTER INSERT INTO Loan_Info_Local (TS, Judicial_Comments) SELECT TS, Judicial_Comments FROM Judicial_Comments Where Judicial_Comments.[TS]=Loan_Info_local.TS |
|
|
|
Feb 2 2012, 02:33 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 1,857 From: BC, Canada |
I am trying to insert the column "Judicial_Comments" from a table called "Judicial_Comments" into Column "Judicial_Comments" in a table called This might be the cause of your problem -- you are using a column with the same name as the table -- this is bound to confuse the query parser. I would strongly suggest renaming the field or the table if possible. Mike |
|
|
|
Feb 2 2012, 03:29 PM
Post
#3
|
|
|
UtterAccess VIP / UA Clown Posts: 25,091 From: LI, NY |
The problem is that you can't reference a field in a table in a WHERE clause like that. That's where the error message comes in. You need to use a DLookup or something else, to pull the value you need to filer the SELECT clause of your APPEND query.
|
|
|
|
Feb 2 2012, 03:44 PM
Post
#4
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
If this returns the correct records:
SELECT j.TS, j.Judicial_Comments FROM Judicial_Comments jc INNER JOIN Loan_Info_local l j.TS = l.TS ...then I would think this would work for the INSERT: INSERT INTO Loan_Info_Local (TS, Judicial_Comments) SELECT j.TS, j.Judicial_Comments FROM Judicial_Comments jc INNER JOIN Loan_Info_local l j.TS = l.TS |
|
|
|
Feb 2 2012, 04:00 PM
Post
#5
|
|
|
UtterAccess VIP Posts: 17,644 From: Don Mills, ON (Canada) |
Have to wonder whether that's really what David wants though, Walter.
That would create a second set of rows in Loan_Info_Local with the same value for TS. Sounds as though he may need an UPDATE query, not an INSERT INTO query! |
|
|
|
Feb 2 2012, 04:17 PM
Post
#6
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
You may be right ... I was just going by his initial comments:
>>trying to insert the column "Judicial_Comments"<< ...and the fact he was using an INSERT query to do the work. ?? |
|
|
|
Feb 2 2012, 04:37 PM
Post
#7
|
|
|
UtterAccess VIP Posts: 17,644 From: Don Mills, ON (Canada) |
Actually, that was the phrase that caught my attention too. As you know, many people think that INSERT works on columns when it only works on rows.
|
|
|
|
Feb 2 2012, 04:53 PM
Post
#8
|
|
|
UtterAccess Addict Posts: 247 |
Thank you everyone for the great comments. They've been very informative.
To clear things up for everyone, I created a column "Judicial_Comments" in the Loan_Info_local table, which is completely blank/null currently. The data I have in the Judicial_comments table I was to copy over into the loan_Info_local table in the column "Judicial_Comments" **I did change the name of my table from Judicial_Comments to Judicial, but I'm still having problems...I believe I do need an update query. So far my code is: USE ClientDB_MASTER Update Loan_Info_local SET Judicial_Comments= Judicial.Judicial_Comments WHERE Judicial.[TS] = loan_Info_local.TS currently I am getting an error that "The multi-part identifier "Judicial.TS" could not be bound." Any help writing this would be greatly appreciated, thank you! This post has been edited by David92595: Feb 2 2012, 05:01 PM |
|
|
|
Feb 2 2012, 05:01 PM
Post
#9
|
|
|
UtterAccess VIP Posts: 1,857 From: BC, Canada |
|
|
|
|
Feb 2 2012, 05:06 PM
Post
#10
|
|
|
UtterAccess VIP Posts: 17,644 From: Don Mills, ON (Canada) |
CODE UPDATE Loan_Info_Local INNER JOIN Judicial_Comments ON Loan_Info_Local.TS = Judicial_Comments.TS SET Loan_Info_Local.Judicial_Comments = Judicial_Comments.Judicial_Comments; While perhaps not a great practice, there's absolutely no reason why you can't have a field named the same as the table. |
|
|
|
Feb 2 2012, 05:16 PM
Post
#11
|
|
|
UtterAccess Addict Posts: 247 |
I'm getting an error:
"Incorrect syntax near the keyword 'INNER'." any idea's? |
|
|
|
Feb 2 2012, 05:23 PM
Post
#12
|
|
|
UtterAccess VIP Posts: 17,644 From: Don Mills, ON (Canada) |
Interesting. That was copied-and-pasted from a working example in Access. Unfortunately, I don't have SQL Server available to test what's different in T-SQL.
Afraid someone with SQL Server will have to find an alternative. Sorry about that! Good luck with your project. |
|
|
|
Feb 2 2012, 05:26 PM
Post
#13
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
Try it this way:
UPDATE Loan_Info_Local SET Judicial_Comments = Judicial_Comments.Judicial_Comments FROM Loan_Info_Local INNER JOIN Judicial_Comments ON Loan_Info_Local.TS = Judicial_Comments.TS |
|
|
|
Feb 2 2012, 05:30 PM
Post
#14
|
|
|
UtterAccess Addict Posts: 247 |
Doug thank you for your attempt.
niesz, it worked. I'd like to thank everyone for helping me on this. In the words of my boss....Sweet David92595 This post has been edited by David92595: Feb 2 2012, 05:33 PM |
|
|
|
Feb 2 2012, 05:39 PM
Post
#15
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
Glad we could all assist. (IMG:style_emoticons/default/thumbup.gif)
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 25th May 2013 - 08:26 PM |