By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,534 Members | 2,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,534 IT Pros & Developers. It's quick & easy.

Uploading Bulk Data into an existing Table

P: 16
I have problem with my append query

I have a query Name NewData with exist in a temporary and i have created an Append query name Appenddata. When i run this query i would like the data from temporary table to be inserted into dbo_Master table which reside in MS SQL server. However when i run the appenddata query in is appending zero data into the master table. The master table has several relationships with other tables - need some help on this.
Jun 6 '18 #1
Share this Question
Share on Google+
7 Replies

Expert 100+
P: 1,430
I feel sure there was an error message generated of why the data was not appended.
Have you bothered to read it, and if so, what did it say?

Jun 6 '18 #2

Expert Mod 10K+
P: 12,366
We can't actually tell you what's wrong with the query when you haven't given us the query. You need to post the SQL at least.
Jun 6 '18 #3

P: 16
Below is my query
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO dbo_TblMaster 
  2. ( HRAPSNo, AlphaCode, FirstName, LastName, Branch, 
  3. Dept, Loc, CostCtr, DateStarted, EndDate, Status, 
  4. PayRate, AnnualSalary, BirthDate, Sex, 
  5. MaritalStatus, Dep, PositionNumber, PositionTitle, 
  6. Netuser, DateCreated, DateModified, [Counter] )
  7. SELECT NewData.HRAPSNo, NewData.AlphaCode, 
  8. NewData.FirstName, NewData.LastName, NewData.Branch, NewData.Dept, NewData.Loc, NewData.CostCtr, NewData.DateStarted, NewData.EndDate, NewData.Status, NewData.PayRate, NewData.AnnualSalary, 
  9. NewData.BirthDate, NewData.Sex, 
  10. NewData.MaritalStatus, NewData.Dep, 
  11. NewData.PositionNumber, NewData.PositionTitle, 
  12. NewData.Netuser, NewData.DateCreated, 
  13. NewData.DateModified, NewData.Counter
  14. FROM NewData INNER JOIN dbo_TblMaster 
  15. ON NewData.HRAPSNo = dbo_TblMaster.HRAPSNo;
Jun 6 '18 #4

Expert Mod 10K+
P: 12,366
You should use code tags when posting code to make it easier to read.

But I see the problem in your query. You're joining to table you're trying to insert into. If you're trying to insert new data, then trying to join to the master table is going to return 0 rows.
Jun 7 '18 #5

P: 16
Thank you Rabbit

I've successfully managed to do remove the inner join and the rows has been picked up when i ran the column, however, I am receiving another error, file conversion error. I will have a workaround with the datatype i guess. Thank you for the assistance.
Jun 7 '18 #6

Expert Mod 10K+
P: 12,366
No problem, feel free to create a new thread if you have another question.
Jun 7 '18 #7

Expert Mod 15k+
P: 31,494
Sometimes linking to the destination table does make sense. Generally when you're trying to add only those records that you know don't exist there already.

In such a case you might use an OUTER JOIN (LEFT JOIN or RIGHT JOIN in Jet/ACE SQL) and include a WHERE clause to include only those records from the destination table where the values are NULL.
Jun 9 '18 #8

Post your reply

Sign in to post your reply or Sign up for a free account.