Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to create

Author  Topic 

Joshrinn
Posting Yak Master

118 Posts

Posted - 2012-05-14 : 22:08:32
How do I dump the data and the required fields on a monthly basis and it exists in the same DB. Could you provide a query of how to do that? Or can I create a view for that? Also it has to be provided on a monthly basis. I am not told that it has to be automated on a monthly basis So i guess it is just for this month.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-14 : 22:12:39
what are required fields you're talking here? Is it like each month only deltas (new changes) or you want entire data to be replicated at the end of each month?

you can use the below logic for get data filtered for current month


...
WHERE yourdatefield >= DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)
AND yourdatefield < DATEADD(mm,DATEDIFF(mm,0,GETDATE())+1,0)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Joshrinn
Posting Yak Master

118 Posts

Posted - 2012-05-14 : 22:31:29
And do I need to create a table with all the data types similar to the required fields?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-14 : 22:40:47
quote:
Originally posted by Joshrinn

And do I need to create a table with all the data types similar to the required fields?


yep..but i'm still unclear whether you need to store detail or aggregate it for each month?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Joshrinn
Posting Yak Master

118 Posts

Posted - 2012-05-14 : 22:43:18
I think just store the detail an provide the data to the higher execs for them to review their monthly report
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-14 : 23:09:42
quote:
Originally posted by Joshrinn

I think just store the detail an provide the data to the higher execs for them to review their monthly report


then your created table should have same fields as your source table with same datatypes

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Joshrinn
Posting Yak Master

118 Posts

Posted - 2012-05-14 : 23:13:23
Thankyou sir. If you could email me I could send you the info. I wante to do that last week but it was not possible in forum.. Hope you understand.
Go to Top of Page
   

- Advertisement -