March 14, 2012 at 10:22 am
Hi,
I am a beginner and don't know where to post my problem, hope i have posted it right. waiting for solution.
I have table with column wise record
example
column name as = idno, Name, April, May, Jun...March_,... Total
Record as = 1, ABC, 1, 2, 3, 4,... 12
and the second table where records are column wise
example
column name= idno, Name, Month , Year, Sub_amount
Records as = 1 ABC, May , 2012 100
second record= 2 ABC June 2012 200
now i want to insert and update the destination table as
column name as = idno, Name, April, May, Jun....March,... Total
Record as = 1, ABC, 1, 0, 0, 4,... 12
means the destination table should have the same structure and content as first table .
but after checking from the second table if records are found for that months for a person then update the amount with 0 for the matching month.
hope i am able to explain the problem correctly.
hoping for a faster response.
Regards
March 14, 2012 at 11:17 am
Well, if you really want a solution you need to do a few things first.
One, read the first article I reference below in my signature block regarding asking for help. Follow the instructions on what you need to post and how to do it. Be sure to also include the expected results based on the sample data.
Two, show us what you have tried to solve your problem.
We are volunteers, not paid staff. Help us help you.
March 14, 2012 at 2:51 pm
Part of the reason that you are having problems is that your first table is not normalized properly. Instead of having a separate column for each month, you should have a separate row for each month. That makes it much easier to do the matches for the updates. You can still pivot the data for reporting, but the base data should be stored on separate rows.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 15, 2012 at 9:20 am
Hi,
Good Evening Sir,
Actually you are right sir, i forget to mention that the first table was # table(Temporary Table).
On that table some of the reports are based.
and I was supposed to read it only.
that was the reason i was making a 3rd table # table (for report) after updating the records form 2nd table.
Sir, for the time being i am keeping this short,
as i am going through the basis Etiquette needed for this site before posting any queries.
Regards
April 23, 2012 at 12:42 am
Refer to this links:
SQL Server: Best way to Update row if exists, Insert if not
======================================
Blog: www.irohitable.com
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply