Thursday 22 April 2010

[Tip] Use GMail to sign up to Web Apps multiple times with same email account

Gmail 512px - See description for downloadI needed to sign up to Twitter for a website I helped develop. I have already set up multiple twitter accounts and used email addresses that I regularly use.

I was looking for a way of using the same email for multiple twitter accounts and found a link which explained that google email considers xxx@gmail.com and xxx@googlemail.com as the same address.

Straight away that gives you a two for one deal on your google email. It doesn't end there. Google email addresses also ignore dots (.) when emails are sent to them. So xx.x@gmail.com is considered the same as xxx@gmail.com. So all variations will end up in the same google mailbox

There are many applications for this feature including spam control however for me it makes it a lot simpler when signing up for web applications like twitter where your email address has to be unique for each account.

Hope this helps someone.

Tuesday 13 April 2010

[Tip] Grant Executor Permissions on All Stored Procedures

This tip works on SQL Server 2005 or above

Most people say that all sql code should be kept separate from your application in the database layer as stored procedures. Whenever I have done this in the past I have had to go into each stored procedure and set the execute permissions for the users. This is time consuming and error prone.

I realised that there must be an easier way of setting the execute permissions so that it only had to be set once for the database after a bit of searching I found the answer.

You just have to run the following sql code on the database.

/* CREATE A NEW ROLE */
CREATE ROLE db_executor

/* GRANT EXECUTE TO THE ROLE */
GRANT EXECUTE TO db_executor


This code creates a new role called 'db_executor' then grants executor permissions to the role.

After running this code you can add a user to the new role by running the following sql code.

EXEC sp_addrolemember 'db_executor', 'sqlusername'


Important Note:
The only draw back with this method of assigning execute permissions is that the user will get permissions to execute any stored procedure already created or created in the future.