title: SQL how do i loop through my list of views
body: <p><strong>Question</strong><br>
  How do i loop though my list of views in my SQL DB?</p>
  
  <p><strong>background and things tried</strong><br>
  I have googled around for about 2 hours now and i have found quite a few ways to loop through different attributes of my DB. I can  loop through a list of tables and a list of columns and a list of counts but i have yet to find anything that allows me to loop through a list of Views.</p>
  
  <p><strong>code to loop through tables i tried to modify</strong></p>
  
  <p><a href="http://www.mssqltips.com/sqlservertip/1905/iterate-through-sql-server-database-objects-without-cursors/" rel="nofollow">link i used to obtain sample code below</a></p>
  
  <pre><code>--List all the tables of current database and total no rows in it
  EXEC sp_MSForEachTable 'SELECT ''?'' as TableName, COUNT(1) 
  as TotalRows FROM ? WITH(NOLOCK)' 
  
  --List all the tables of current database and space used by it EXECUTE sp_MSforeachtable 'EXECUTE sp_spaceused [?];'; 
  GO
  </code></pre>
  
  <p><strong>sudo code for what i want to do</strong></p>
  
  <pre><code>loop through each view in list
  run query here for each view
  output results
  </code></pre>
  
  <p><strong>request for help</strong></p>
  
  <p>Can anyone link me to more information about how to do this or provide some sample code? All help is greatly appreciated! Thanks!</p>