17 February 2009

Script to change object owners

I have recently started working with SQL Server 2005, and the first thing I noticed is that I cannot automatically set the owner of a script at creation time.  SQL Server 2005 automatically adds my user name as the object owner.

The following script, adapted from Scott Forsyth's blog, batches up the changes.  Change the name of the old owner (@old) and the new owner (@new) and it will change the ownership for all the database objects.

Script to update SQL Server Object Ownership

DECLARE @old nvarchar(30), @new nvarchar(30), @obj nvarchar(50), @x int;

SET @old = 'domain\user-name';

SET @new = 'dbo'SELECT @x = count(*);

FROM INFORMATION_SCHEMA.ROUTINES a

WHERE

  a.ROUTINE_TYPE IN('PROCEDURE', 'FUNCTION')

  AND a.SPECIFIC_SCHEMA = @old;

while(@x > 0)

  BEGIN

    SELECT @obj = [SPECIFIC_NAME]

    FROM INFORMATION_SCHEMA.ROUTINES a

    WHERE

       a.ROUTINE_TYPE IN('PROCEDURE', 'FUNCTION')

       AND a.SPECIFIC_SCHEMA = @old;

     SET @x = @@ROWCOUNT - 1;

    EXEC sp_changeobjectowner @obj, @new;

END

02 December 2008

Direct Link to a new Google Spreadsheet

One of the advantages to having web-based documents is that you can open them from any desktop in multiple browsers.  

I use Google Apps for my online office suite, but find that Zoho is a strong competitor for many reasons. One thing I like about Zoho is that they publish a URL that allows you to open a 'scratch' worksheet.  Zoho does not require an account for this spreadsheet.  If you have a Zoho account, you have the option of saving it when done. Otherwise, you can quickly do spreadsheet calculations, export it, save it, or close it when you are done.

But what about Google Apps? Do they publish a similar URL?  It turns out they do, but it is hidden.   After trial and error (and watching my browser carefully), I was able to come up with the URL for a new Google Apps spreadsheet. (Note: This URL requires a Google Apps account - which is free.)

The URL is as follows:

http://spreadsheets.google.com/a/[Google Apps Url]/ccc?new&hl=en

Where [Google Apps URL] is the URL to your Google Apps.  Just post it on your iGoogle bookmarks widget and you can start launching new spreadsheets right from your homepage.