Showing posts with label SQL 2008. Show all posts
Showing posts with label SQL 2008. Show all posts

Thursday, August 11, 2011

Script to Change the db owner of all databases

I was in need of a script to change the owner of all the database in a server. I checked in the internet but couldnt find any thing so I made this by myself :)


DECLARE curDBNames CURSOR READ_ONLY FOR  SELECT name FROM sys.databases where
name NOT IN('master', 'model', 'msdb', 'tempdb','resource') and state = 0
DECLARE @dbName as varchar(1000)
DECLARE @Sql as varchar(1000)
declare @dbOwnerName as varchar(100)
set @dbOwnerName = 'sa'
OPEN curDBNames
      --PRINT @@ROWCOUNT           
      FETCH NEXT FROM curDBNames INTO @dbName
      WHILE @@FETCH_STATUS = 0
      BEGIN
     
            set @Sql = 'use [' + @dbName + ']'
        exec (@Sql)                      
        set @Sql = 'sp_changedbowner ' + @dbOwnerName
        exec (@Sql)
            FETCH NEXT FROM curDBNames INTO @dbName
      END  
      CLOSE curDBNames
      DEALLOCATE curDBNames
Hope you like the script. Let me know if something doesnt work. As usual pls double check before you try this in your production environment.

Tuesday, November 16, 2010

Security loop Hole in "Security Admin " Role

Today I found out one interesting article, which describes the loop hole in security admin role, which has an ability to elivate an user to "sys admin". Please find the article here.

Monday, March 10, 2008

SQL 2008 Beta Website

Im back to technical blogging after a very long gap. In the mean while SQL 2008 is out, most of the guys should be aware of that fact. I was just going through the mails from the atlanta.mdf(believe me its a very active sql server group that I know, they have monthly sessions and speeches, believe me they are wonderful.) you can find some good presentations of those sessions here .

From "atlanta.mdf" I happened to find very good website for SQL 2008 beta . I just tried to use it, its really nice. probably you guys can try to have a peek look into that website.