-1

I am using SQL Server Management Studio v17.4

I have a view v_fetch_rates. I have created a table using the command

SELECT  *
INTO    RATES
FROM    v_fetch_rates

My question is how do I update the table RATES on daily basis automatically? Is there a way to do it by existing view or do I need to write stored procedure for this?

I did some googling but it confused me even more.

I have never created a job before so any help/resources to refer would help a lot.

aduguid
  • 3,099
  • 6
  • 18
  • 37
Natasha
  • 175
  • 1
  • 3
  • 12
  • 1
    Is there a reason why you can't just select from v_fetch_rates and you want a clone table? – George Menoutis Nov 07 '18 at 11:09
  • To expand on the answer below, the view could also be slow because it's poorly written (non-SARGable expressions, for example). If so, you would be better off improving the view to make it run far quicker. Perhaps you could post the definition of the the View? – Thom A Nov 07 '18 at 11:11
  • The view is further used in tableau which is impacting the performance of dashboard. It is quite complex and refers 5 tableas (updated daily) with multiple joins. It would be good to create a table and use that in tableau or any other BI tools – Natasha Nov 07 '18 at 12:59

1 Answers1

2

If the issue is that the view is slow (because of its definition or the amount of data it returns) and you want to materialized the data in order to improve performance you can simply create a indexed view.

The idea is simple - creating an index on the view forces the engine to materialized it. Of course, there are various limitations and requirements of having index view. You can find more information in the specified link.

If you just want to have the data in a table and populated in on daily basis, you can:

  • create simple stored procedure which is truncating the current table and populating the data again calling the view
  • create a complex routine, which will modify (insert/update/delete) data only if needed
gotqn
  • 42,737
  • 46
  • 157
  • 243