Browse by Tags

Tagged Content List
  • Blog Post: Running a SQL Statement on all Databases

    exec sp_MsForEachDB 'SELECT "?", 1' The ? will be replaced by the current database name. To run a query that references a table, you need to make sure that the table exists first, as this query will run on system databases as well.
  • Blog Post: Nested For-each Loops in SQL

    Usually, it's not recommended that you use loops in SQL unless you need to. You should use set-based queries instead. However, if you need to, there are many ways to loop, one of them is using cursors. For example, let's say that you have multiple DBs and you need to select count(*) from some tables...
Page 1 of 1 (2 items)