Thursday, 13 June 2013

Grant View Definition Permission - SQL Server



To Grant View Definition Permission to a User or Role in SQL Server

To turn on this feature across the board for all databases and all users you can issue the following statement:
USE master
GO
GRANT VIEW ANY DEFINITION TO PUBLIC
To turn on this feature across the board for all databases for user "User1" you can issue the following statement:
USE master
GO
GRANT VIEW ANY DEFINITION TO User1
                                 SQL Server Migration Notes/Tips

Migration means Side-by-Side as mostly in real time(Production), In-Place Migration is NOT recommended due to its more down time till the newly built instance & database are ready.

Use of UAR - upgrade adviser report

When consolidating the instances on migration(assumes Hardware suffice) Conflicts may be @:
Database names
SQL Server Jobs names
Agent Jobs History - use Agent job's id to make related entry in the new msdb
Maintenance plans - Saved Schedules
SSIS packages -




-SR-

The " :setvar " only works in SQL command mode, within normal SQL execution in the management studio 
it throws the error > Incorrect syntax near ':'

Now, need to change the query window to SQLCMD mode and run the query.
ie: In SSMS menu items, Query->SQLCMD mode


/*
    Deployment script for master
*/

    GO
    SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;

    SET NUMERIC_ROUNDABORT OFF;

    GO
    :setvar DatabaseName "msdb"                                                             :setvar DSRDatabaseMailProfile "Production Hub (DSR ODS)" 


This is the new way MS prompting for the License terms when we login for the first time to a newly build server(Win2008R2 in this case).