Guest User

Untitled

a guest
Jan 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. declare @dbname nvarchar(128)
  2. declare @dynamic_command nvarchar(1024)
  3. set @dynamic_command = null
  4.  
  5. declare resume_cursor cursor for
  6. select 'ALTER DATABASE [' + name +'] SET HADR RESUME;' from sys.databases where group_database_id is not null
  7. open resume_cursor
  8. fetch next from resume_cursor into @dbname
  9. while @@fetch_status = 0
  10. begin
  11. set @dynamic_command = @dbname
  12. exec sp_executesql @dynamic_command
  13. set @dynamic_command = null
  14. fetch next from resume_cursor into @dbname
  15. end
  16. close resume_cursor
  17. deallocate resume_cursor
Add Comment
Please, Sign In to add comment