Monthly Archives: January 2012

6 ways to get free SQL Server 2012 Training

I always get excited when a new version of SQL Server gets released and rumor has it that  SQL Server 2012 will be released on March, 7th 2012. Why do I get excited? Well its quite easy, I know that each new release includes new features. These new features make my job easier. How do I know that these new features make my job easier? I know because I test them out and attend training sessions to see how other people are using them.

This year Microsoft is teaming up with the Professional Association of SQL Server Professionals (PASS) to provide several opportunities to give free SQL Server 2012 training.   Here are six ways you can learn about SQL Server 2012 and it won’t cost you a cent.

Online Labs

I love to get my hands dirty and throw things against the wall and see what sticks. Microsoft provides several virtual labs that allow you to do this without worrying about your servers.  If you want to checkout upgrading to SQL 2012, AlwaysOn Availability Groups or Installing SQL 2012 on Windows Core they have labs up and waiting for you.

Special Ops Tour

If you like to physically experience a launch event and rub shoulders with others who are using SQL Server you have to take part in the Special Ops Tour.  The Special Ops Tour is a 12 city event where Microsoft experts and local DBA’s will show you the must use features coming in this new release.  You can still sign up now. Hopefully, there is an event near you.

SQL Server 2012 Virtual Launch

Microsoft is also providing an all day virtual launch on March 7th that will include several topics on Mission Critical Confidence, Cloud on your Terms and Breakthrough Insights.  You can review the agenda and there still is room to sign up.

24 Hours of PASS

Once again, PASS is gearing up to deliver another 24 hours of PASS on March 21, 2012.  For those who don’t know 24 hours of PASS is  an in-depth look at the hottest SQL Server topics over 24 back-to-back free technical webcasts. You can gain access to the best SQL Server training and several of these session will be focused on SQL Server 2012. For more information visit the 24 hours of PASS website. If you want to speak get your abstract submitted now. The deadline is today!

SQL Saturday

SQL Saturday is an all day multi-track training event for SQL Server professionals and those wanting to learn about SQL Server. These events are spread all across the USA and the globe.

User Group Meetings

User Groups are monthly or bi-monthly meetings held to allow PASS members to connect, share and learn on a local level. There are several User Group’s spread out across the country.  Do you wonder if there is a user group in your area? You can find all the user groups here.

8 steps to moving database users from SQL 2005 to SQL 2008

Have you ever had to complete an upgrade where you had to uninstall SQL Server 2005 and install SQL Server 2008 on the same box? If so, how do you make sure the new install had the same security objects?  For me, the answer was lets be safe instead of being sorry.  I would script out all the existing server and database security objects so they could be verified and implemented if needed.

Not only is this a good practice for migrating your servers but the following post could be useful for a security audit.   I also want to mention if you are allowed to install tools on the box you can download SQLPermissions its a free tool provided by Idera to generate a script to move security objects during a migration.
[Update 1/28/2012 - USER_NAME() was replaced with SCHEMA_NAME() in the Explicit Permissions section]
** Run scripts at your own risk. I don’t assume any responsibility for these scripts on being ran in your environment. As always, I recommend testing in development before running in production :-) **

Logins

The very first step to connecting to an instant of SQL Server is to connect or login. In order to connect you must have a login. Therefore, our first step will be to actually copy the logins. I know, you might already be wondering how do I get the passwords moved over for SQL authenticated logins? Microsoft has a KB article (918922) that walks you through this process. Make sure you checkout the remarks section before running the code on a production box.

Server Level Security

Logins are nice but actually useless unless they have access to connect. Therefore, we might want to allow these logins to connect. You might also want to make sure a subset of the accounts  have access to view the DMV’s. This and other server level permissions can be scripted out with the following code below.


SELECT	sp.state_desc,
	sp.permission_name,
	principal_name = QUOTENAME(spl.name),
spl.type_desc,
	sp.state_desc + N' ' + sp.permission_name + N' TO ' + cast(QUOTENAME(spl.name COLLATE DATABASE_DEFAULT) as nvarchar(256)) AS "T-SQL Script"
FROM sys.server_permissions sp
inner join sys.server_principals spl on (sp.grantee_principal_id = spl.principal_id)
where spl.name not like '##%' -- skip PBM accounts
and spl.name not in ('dbo', 'sa', 'public')
order by sp.permission_name, spl.name

Server Level Roles

Now that we can login we might want to take this to the next step. We may actually like to perform some actions. Well, if your instance includes third party application databases there could be a good chance that it depends on its login having sysadmin access. Yes, in case you were wondering this is poor security design but the point is your logins may depend on server level roles to have access to the database objects.  Here is a script you can use to script out server level roles.

SELECT  DISTINCT
QUOTENAME(sp.name) AS "ServerRoleName",
sp.type_desc AS "RoleDescription",
QUOTENAME(m.name) AS "PrincipalName",
m.type_desc AS "LoginDescription",
'EXEC master..sp_addsrvrolemember @loginame = N''' + m.name + ''', @rolename = N''' + sp.name + '''' AS "T-SQL Script"
FROM sys.server_role_members AS srm
inner join sys.server_principals sp on (srm.role_principal_id = sp.principal_id)
inner join sys.server_principals m on (srm.member_principal_id = m.principal_id)
where sp.is_disabled = 0
and m.is_disabled = 0
and m.name not in ('dbo', 'sa', 'public')
and m.name <> 'NT AUTHORITY\SYSTEM'

Database Level Security

Now that your logins can connect you need to make sure that they can connect to the databases you migrated over.  Remember those third party apps that skipped the process of doing a  security design?  They will use sysadmin access so database level security will be included.  Hopefully, your applications are not one of those. Just like server level security you can also have database level security. Make sure you run the script below and save your results.


SELECT  dp.state_desc,
dp.permission_name,
QUOTENAME(dpl.name)  AS 'principal_name',
 dpl.type_desc,
 dp.state_desc + N' ' + dp.permission_name + N' TO ' + cast(QUOTENAME(dpl.name COLLATE DATABASE_DEFAULT) as nvarchar(500))  AS "T-SQL Script"
FROM sys.database_permissions AS dp
INNER JOIN sys.database_principals AS dpl ON (dp.grantee_principal_id = dpl.principal_id)
WHERE dp.major_id = 0
and dpl.name not like '##%' -- excluds PBM accounts
and dpl.name not in ('dbo', 'sa', 'public')
ORDER BY dp.permission_name ASC, dp.state_desc ASC

Database Level Roles

Just like the SQL Server instance your database also has roles.  Many times I will see applications that don’t require sysadmin on the instance but do require db_owner access in the database.   This is also a bad security design practice as db_owner can do anything against that database. Hopefully, your application has object level explicit permissions as needed. Once again, I would recommend pulling this information in case its needed after your migration.


SELECT DISTINCT
QUOTENAME(drole.name) as "DatabaseRoleName",
drole.type_desc,
QUOTENAME(dp.name) as "PrincipalName",
dp.type_desc,
'EXEC sp_addrolemember @membername = N''' + dp.name COLLATE DATABASE_DEFAULT + ''', @rolename = N''' + drole.name + '''' AS "T-SQL Script"
FROM sys.database_role_members AS drm
inner join sys.database_principals drole on (drm.role_principal_id = drole.principal_id)
inner join sys.database_principals dp on (drm.member_principal_id = dp.principal_id)
where dp.name not in ('dbo', 'sa', 'public')

Database Level Explicit Permissions

Finally, we will get to the area of security where I hope to see many entries. If someone, tasked me with designing their the security model for their application I would make sure stored procedures controlled the data access and that application users could only execute the stored procedures. This way there would be very minimal risk of data loss as the users wouldn’t have direct access to the tables. They would only access data needed by the business logic provided in the database objects. You can pull this information from the code below.


SELECT    dp.state_desc AS "StateDescription" ,
dp.permission_name AS "PermissionName" ,
SCHEMA_NAME(obj.schema_id) AS [Schema Name],
obj.NAME AS [Object Name],
QUOTENAME(SCHEMA_NAME(obj.schema_id)) + '.' + QUOTENAME(obj.name)    + CASE WHEN col.column_id IS NULL THEN SPACE(0)           ELSE '(' + QUOTENAME(col.name COLLATE DATABASE_DEFAULT) + ')'      END AS "ObjectName" ,
QUOTENAME(dpl.name COLLATE database_default) AS "UserName" ,
dpl.type_Desc AS "UserRoleType" ,
obj.type_desc AS "ObjectType" ,
dp.state_desc + N' ' + dp.permission_name + N' ON '    + QUOTENAME(SCHEMA_NAME(obj.schema_id)) + '.' + QUOTENAME(obj.name)    + N' TO ' + QUOTENAME(dpl.name COLLATE database_default) AS "T-SQL Script"
FROM    sys.database_permissions AS dp
INNER JOIN sys.objects AS obj ON ( dp.major_id = obj.[object_id] )
INNER JOIN sys.database_principals AS dpl ON ( dp.grantee_principal_id = dpl.principal_id )
LEFT JOIN sys.columns AS col ON ( col.column_id = dp.minor_id  AND col.[object_id] = dp.major_id)
WHERE    obj.name NOT LIKE 'dt%'
AND obj.is_ms_shipped = 0
AND dpl.name NOT IN ( 'dbo', 'sa', 'public' )
ORDER BY    dp.permission_name ASC ,    dp.state_desc ASC

Orphaned users

If logins are not brought over correctly you may notice that they are not mapped correctly with the user account that exists in the database security (Logins section above should catch this).  The following is an explination that comes from BOL.

A database user for which the corresponding SQL Server login is undefined or is incorrectly defined on a server instance cannot log in to the instance. Such a user is said to be anorphaned user of the database on that server instance.

You can find and fix orphaned users by following the instructions provided here.

Validate User Accounts

Finally, yes when possible lets make sure the user accounts work.  I know this might be common sense but you don’t want to cut something over with out testing and verifying connectivity.

Speaking at the Columbus SQL Server User Group

This week on Thursday, January 12th, 2011 a 6pm I will be speaking virtually at the Columbus, OH SQL Server User Group.  I will be giving an introduction to Policy Based Management.

If you are a chapter leader and would be interested in having me speak at your user group contact me.

Abstract

This talk will give you an introduction into monitoring SQL Server using Policy Based Management and Central Management System which is provided out of the box with SQL Server 2008. I will then show you how you can combine these features with the Enterprise Policy Management Framework on codeplex to provide monitoring for your whole SQL Server farm. This topic assumes you know nothing about PBM and CMS and will include lots of examples with only a few PowerPoint slides.

Top 4 ways I will contribute to the SQL Community in 2012

One of my friends, Tom LaRock asked, “What do you want to do for your #sqlfamily in 2012?” Below is how I plan contribute to the SQL Community, and my #sqlfamily in 2012.

  • Bring  SQL Saturday to a new city
    Anyone who knows me in the community knows I am a huge fan sucker for a SQL Saturday. I have had the pleasure of being a host, attende, and a speaker. This year I am looking forward to being a volunteer and sharing all my knoweledge to bring a SQL Saturday to a new city.  With that said, there is a city very close to me that has never hosted one.  The ball is already rolling and I look forward to helping this chapter host their first SQL Saturday in 2012.
  • Help Chapter Leaders
    Being a chapter leader I personally know it can be hard running a user group. I was very lucky and thankful to get a lot of help.  I look forward to helping other chapter leaders who can use a hand. I am willing to help connect leaders to a sponsors; help leaders find swag, find books, find a speaker or anyting else. I am game and looking forward to helping.
  • Give Virtual Presentations
    Typically I do at least four presentations a year.  To this point I have never done a virtual presentation. This will change shortly as I am speaking  at the Columbus User Group virtually this week.
  • Mentor
    I have been blessed with having good mentors in my career. Without them I wouldn’t be where I am today. There advice and guidence has been very valuable.  I reciently started mentoring a DBA but would more than willing to help others out. If you would be interested please shoot me an message.