June 2, 2016 at 12:38 pm
SQLTeam.com Forums
If someone answers your question or provides a helpful response, please take a second to LIKE that reply. It's a nice way to say Thank You to someone that helped you out.
You do that by clicking on the little heart at the bottom of a post (either topic or reply).
And if you're looking at a thread and see a good answer, please feel free to LIKE that. Anyone can do it, not just the original author. And yes, you can like multiple threads in a post.
Create a query to update or insert between date ranges in a table
Transact-SQL
Arihant
8m
HelloTeam,
My table is having structure
Id A B C D E Fromdate todate
1 1 2 6 4 9 1900 1950
1 2 3 6 8 3 1951 2000
1 3 6 6 1 1 2001 9998
2.....
Here the A B C D E are attributes for a fund 1.
Date range defines their value between the intervals.
Now in the input i can get any attribute of fund with new value in a defined interval or may be the new interval. But i will also get the previous values also in the result set.
For eg i am getting the input data
Id Attribute Value fromdate todate
1 B 10 1900 1930
1 B 4 1931 2050
1 B 7 2051 9998
Now i need to update my final table as:
Id A B C D E Fromdate todate
1 1 10 6 4 9 1900 1930
1 1 4 6 4 9 1931 1950
1 2 4 6 8 3 1951 2000
1 3 4 6 1 1 2001 2050
1 3 7 6 1 1 2051 9998
So basically we are breaking the inetrvals based on value and updating values acc..
Always the input data will be from 1900-9998 range
And the table on which we are updating will also be from range 1900-9998.
Pls replay asap.
Thanks in advance.
Thanks,
Arihant Jain
June 2, 2016 at 1:08 pm
Please don't cross post. It fragments the replies. Please respond to http://www.sqlservercentral.com/Forums/Topic1791754-3077-1.aspx
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply