Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

Refresh multiple views

Hi, first time question here, so please be gentle.
I've detached and attached a CRM database but need to refresh the views. Can I do this in one go, or am I studk with doing each view individualy.

Many Thanks. Please don't hesistate if you need more info, which I presume you all will.

Mark
0
mark_uunix
Asked:
mark_uunix
  • 2
1 Solution
 
BrandonGalderisiCommented:
define "REFRESH VIEWS"

if you mean that the definition of the underlying tables, from which you had views doing "select *" then the command you want to issue is sp_refreshview and I can help you automate that.  But before we do that, do you mean that or do you want to refresh the data in views?

Because data isn't stored in views (unless it's indexed but we won't get into that).  A view is like a saved SQL statement.  It allows you to repeat large, possibly complex SQL statements as a simple select.

So if you had:
select * from Table1 t1 join table2 t2 on t1.id=t2.id

you could write this
create view vw_MyView
as
select * from Table1 t1 join table2 t2 on t1.id=t2.id
go

which would allow you to do this:

select * from vw_myView

This simplifying the SQL select statement.
0
 
mark_uunixAuthor Commented:
Many thanks Brandon for your reply, it was EXEC sp_refreshview command that I was looking at - at first, turns out, it was permissions issue anyway.

Mark
0
 
BrandonGalderisiCommented:
How did you discover it was a permission issue and what kind of permission issue?
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now