Author Archives: johnsterrett

Speaking at Pittsburgh Powershell User Group

Tomorrow, May 15th at 6pm I will be joining the script club and give a presentation on how DBA’s can leverage powershell to do their job quicker and automate processes.  It’s not too late to sign up. If you will be near the north shore I highly recommend checking it out. You can also follow the Pittsburgh PowerShell User Group to checkout their future meetings.

 

 

Getting Inspired with SQL Someday

Recently, I caught my during a kickoff with a new client saying, “Hello I am John, and I love SQL. If SQL Server asked for more heart I will not say no!” That’s right folks I am a very lucky guy. Everyday I get to wake up stroll on down to the basement and do what I love to do. I get to work with databases and work on some really cool projects that improve my skills as a Senior DBA database architect. Every once in a while, even I need to be inspired and reminded that its okay to not get everything done today. Therefore, I make sure I watch the SQL Someday presentation by Thomas LaRock (blog | twitter) at last years SQL Inspire event created by SQL People for SQL People at least once a quarter. I always try to remember the following quote, “There are seven days in a week and someday is not one of them!”

“There are seven days in a week and someday is not one of them.  Someday may never happen, there are somedays that already happened and you never knew it and somedays that might still become true.”

Lessons Learned

I am a driven person. I am a goal setter and I like to accomplish my goals and move on to the next ones. Sometimes I am so locked in on my next goal I am not spending time appreciating the goals that were accomplished. I also need to remind myself that even though I love SQL and the SQL Community there are other things that I love. Someday may never happen, someday might have happend and I didn’t know it and someday may actually happen. I can easily think of an occasion where someday happend and I missed it. The biggest benefit of working from home is that I can go on a walk with babybeluga and my wife if I can step away from the computer at 6pm. Each night I continue being plugged in at 6pm is an opportunity missed to spend some special time with my family. Therefore, I need to make a better effort to stop and align myself towards whats important. This doesn’t mean I cannot accomplish everything it just means that Someday might not be today. Someday might never happen and I am perfectly fine with this as long as I prioritize everything correctly and make sure I get to the items in life that really matter the most to me.

SQL Inspire On Demand

If you missed the first SQL Inspire event in 2011 I have some good news. All the sessions were recorded and are available to view for free online. The following are videos on demand that you can watch to get Inspired and find that extra bit of motivation needed to help you get to the next level.

  • Telecommuting and the Virtual Office: Making the Case to Convince your Boss by Robert Pearl
  • Finding Balance by Steve Jones
  • SQL Someday by Tom LaRock
  • Navigating the New Job Market by Michael Coles
  • Big Data, BI, Big Deal! by Andrew Brust
  • DBA to CEO by Michael Corey
  • Professional Services 2.0 by Brian Moran

I hope this post leads you to some great material to help keep you inspired. I also hope someone can learn from my lesson and make sure your work life is balanced towards your long term goals. Have you noticed any somedays that were missed? If so, please feel free to share them with us.

Let’s Meetup [Updated]!

I have a confession to make. I like to meet people who also work with SQL Server. There are so many different ways to use SQL Server. I love to hear how people are using it differently than me.  One of the easiest ways to accomplish this is to connect with people and start a conversation at SQLSaturday’s, User Group Meetings and PASS events like SQL Rally coming up in Dallas in May. Once upon a time, I would attend similar training events and was so shy I didn’t connect with anyone. Why didn’t I connect with anyone? Mainly, because I was afraid. If this is you, you are not alone I was in the same place as you. In fact, let’s meetup at one of the events listed below.

NOTE: The following schedule has been updated on May, 17th 2012

SQL Saturday #107 (Houston, TX) on April 21st

I will be presenting my Evaluating your Daily Checklist with PBM and CMS presentation. I always look forward to SQL Saturday’s in Houston as this gives me the opportunity to visit my family and my #sqlfamily in the same trip. If your in Houston its not too late to sign up.

WVPASS (Wheeling, WV) May 24th

I will be presenting “DBA’s use RML Utilities to help get your next raise!” If your in Pittsburgh or Morgantown area make the drive out. Anyone, can still signup for this free event. Not only will you learn how to prove that your new indexes or application upgrade will improve performance but you will get free pizza. As a bonus, you will also get to meet some cool DBA’s in Wheeling, WV.

SQL Satuday #117 IN COLUMBUS, OH ON June 2nd

I am looking forward to my first SQL Saturday in Columbus, OH. I will be giving my Performance Tuning for Pirates presentation. Columbus is only a two hour drive and I hope to bring #babybeluga and the wife out with me. I think they would have a blast at the Columbus Zoo.

SQL Saturday #121 in Philadelphia, PA on June 9th

Do we really need to say more?  I cannot wait for SQL Saturday in the city of brotherly love.  The schedule hasn’t  has been posted and I will be giving my Performance Tuning for Pirates presentation. I look forward to learning, connecting and sharing.

Pittsburgh SQL Server User Group (Pittsburgh, PA) on June 26th

I will be presenting, “Performance Tuning for Pirates!” in Pittsburgh. Pittsburgh has a great SQL Server User Group and it’s always an honor to present for this group.

Performance Virtual Chapter – June 28th

I will be presenting, “Performance Tuning for Pirates!” Being that this is a virtual chapter I will not be presenting in person. This doesn’t mean that we cannot connect and chat.  We always have twitter so send me shout out before or after the session.

#tsql2day – Contained Databases are sexy and they know it!

This month Nigel Sammy (blog | twitter) is hosting this months T-SQL Tuesday and the chosen topic is  What do you think is a useful feature of SQL Server 2012? Therefore, I am going to write about a topic that isn’t getting much pub in the streets like AlwaysOn Available Groups or Columnstore. But that’s okay because Contained Databases are sexy and they know it!

Contained Databases

A contained database is a database that is isolated from other databases and from the instance that hosts SQL Server. Why could this be helpful? Well lets think about logins. What happens when you migrate a database from one instance to another? You have to copy over the logins and unorphan the logins if they are orphaned.  Wouldn’t it be nice to keep the logins contained in a database so they weren’t depended on logins created on the instance? I think so, especially for some third party applications that think they need sysadmin access.  Now why would I be worried about databases moving between instances? This is where Always Avaiable groups come in. I know what your thinking, he just lied and is talking about Always Available groups. Yep, your right but here is my point.  If the users are contained users for a database belonging to an Always Available group, during a failover, people would be able to connect to the secondary without creating logins on the instance hosting the secondary. This was a cool lesson learned quickly while building my virtual sandbox to test Always Available Groups.

Before you consider using contained databases you have see if your user databases are able to be a contained databases. If you are using replication, change data capture, or change tracking then contained databases may not be for you. As always, review Books Online for more details and make sure you test this out in development before using it in production.

Bonus – Get your Learn On!

Are you interested in learning more about SQL 2012? Do you wonder where you can find free resources? If so, the links I am using are included in this paragraph to help you brush up on the good stuff. You can download a free book, get your hands dirty with several virtual labs, view several videos and demos, Watch recorded sessions from #24HOP and attend the Microsoft Virtual Academy SQL 2012 training sessions.

24 Hours of PASS – Get your free downloads!

I am speaking at 24 Hours of PASS

I am speaking at 24 Hours of PASS

Thank you to everyone who attended my #24HOP session on Performance Tuning for Pirates! You can now download my slide deck, t-sql queries, and view my reference links.  If you have any questions about the tools presented feel free to contact me and I will  try to help you out or point you in the right direction.

 

Help me.. Help you…

Yes, its that time again.  I need your help to help me help you. Its time to vote in the Community Choice section for the SQL Rally PreCons.  I know, if you looked at the abstracts you might be wondering how can I help you? Your not even on the PreCon ballet. That is correct, but here is the kicker. I will be joining my good friend Joey D’Antoni (blog | twitter) with his SQL 2012 and Disaster Recovery–Getting Your Organization Ready session.  I look forward to sharing some HA/DR war stories and demos.

What is Community Choice?

There are two slots still open for SQL Rally 2012 in Dallas and the programming committee wants the community to weigh-in on the final selection. This is a very cool idea and I am glad they are allowing the community to select some all day PreCons.

How can I vote?

If you are a database professional it’s not too late to vote. You can cast your vote here. If you are not a current member of The Professional Association for SQL Server (PASS) you can sign up for a free and then go back to the community choice page to vote.

Voting closes Thursday, February 9th at 5:00pm central time.

Move the Quorum Disk Group

Recently, I worked on a project to migrate data from a four node cluster (3 active, 1 Passive) from an old SAN to a new SAN using SAN Copy by EMC. Once, the data was copied I failed the services around and verified that each service would work on each node. Here is how I moved the quorum disk to each node.

To move the quorum disk group you have to run the command listed below in the command prompt. Make sure you run the command prompt with Administrator rights or you might see an access is denied error.

Cluster group “Cluster Group” /move:<newnode>

If the cluster disk group was active on the db1 node and you wanted to migrate the group to db2 you would use the command below in the command prompt.

Cluster group “Cluster Group” /move:db2

If you like this post check out  my post on renaming the server name for a SQL Cluster or my other cluster posts.

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.