In Tuesday’s class we covered the different authentication methods as well as did a quick walk-through of the SQL Management Studio interface. In today’s lecture we’ll continue looking at SSMS. Some of the things we look at include how to create a query against a database, brief intro to the Profiler tool as well as a brief intro to the Database Engine Tuning Advisor.
Warning: Video is hosted by YouTube. If you cannot see it your company might be blocking that site. My apologies, I will have an alternative method available in future.
In addition to watching the video you guys have a little bit of homework. Don’t worry, it’s not hard. Just try a few of the things on this list to help you get accustomed to the environment.
Connect to your local database using SSMS using Windows authentication
Browse to the AdventureWorks Database, Open up the Tables folder and select the TOP 1000 Rows from Person.Address table. In comments below, post the AddressLine1 for AddressID 17.
[Extra Credit] Browse to the Security folder, Open up the Logins folder. Create a new login called testlogin. Make it SQL Server authentication, give it password of ‘P@$$w0rd’ (NOTE: Thanks to Brian Kelley for pointing this out. Do NOT use your production servers/databases for this excercise. Also NEVER use password this simple in your production environment…ever. Security will be covered in a few weeks.), make its default database AdventureWorks.
Next week we’ll be covering Backup and Restore with Argenis Fernandez (Blog | Twitter). The full syllabus for the semester will be posted shortly.
Ok everyone, please take your seats. Thank you. Welcome to SQL University, my name is Jorge Segarra and I’ll be helping you start on your journey to SQL Server. You’re here because you either are curious about SQL Server and wish to start down that path or you’ve become an accidental DBA in your organization and require knowledge to get your new job done. I’ll be one of your online professors along this journey. Since this is the orientation we’ll start with some basics you’ll need for this semester.
School Supplies (aka stuff you’ll need for SQL University):
SQL Server 2008 Express (Runtime with Management Tools) – Download link
NOTE: If you already have a SQL 2008 instance to play with don’t worry about step 1. This is meant for those who are starting from scratch. For stuff like SQL Server Agent we’ll discuss it but assignments won’t depend on you having it.
What I’ll ask of students is that you go over this list and get yourself prepared. First day of class will start on Monday, September 28th and we’ll be covering how to use the basic management tool for SQL Server: The SQL Server Management Studio. In the meantime here’s your homework assignment:
1. Install SQL Server 2008 Express (Runtime with Management Tools)
NOTE: AdventureWorks is a ficticious bicycle company. The databases are example databases that are commonly used for practice with SQL Server so that students can learn basics from. Please Use the Recommended Download (All Databases.x86.msi)
3. Go through the whole SQL Tutorial on W3 Schools (If you don’t know SQL syntax consider this MANDATORY. If you already know the language and you’d like a refresher go ahead and do the tutorial anyways)
4. Either watch the video (about 34 minutes) or download and read through the Relational Database Theory paper to familiarize with key concepts and theories.
So now that you have your homework let’s cover how SQL University is going to work. I have amassed a few fellow faculty members that will help me out with classes this semester. Each staff member will be blogging on a different beginner topic and tagging their post with SQL University. I will be linking their classes here so you can have a central place to come back to and see all of the great SQL University content at a glance. With each topic/class I ask that students try to be active and ask questions in the comments section of each post. The more questions posted the more answers can get posted and the more we ALL learn!
I’m REALLY psyched about SQL Saturday as there are going to be some awesome presenters there such as Andy Leonard (Blog | Twitter), Ken Simmons (Blog | Twitter), Joe Webb (Blog | Twitter), Brian Knight (Blog | Twitter), Kevin Kline (Blog | Twitter), Andy Warren (Blog | Twitter), Buck Woody (Blog | Twitter), Kendal Van Dyke (Blog | Twitter), Chad Miller (Blog | Twitter) and many more! The speaker lineup looks like a veritable PASS Summit East Coast edition. If you can’t make it to the Summit this year (and I highly encourage you to do so if you can) then definitely try to make it to SQL Saturday #21!
And as if the lineup of talks at the SQL Saturday event wasn’t enough to blow your mind, the week leading up to it there is a week of day-long training seminars! Again, this looks like a rock star line up featuring Andy Warren, Brian Knight, Kevin Kline, Andy Leonard and Buck Woody. Each session is $150 and WELL worth the investment.
Recently I was thinking about my experiences with all of the SQL Server learning events and while they have all been absolutely awesome I realized one thing: they’re that awesome for me because I know what’s going on. By that I mean I’ve been around SQL Server for awhile now so when I attend the sessions I already have a basic understanding of everything that is being discussed. Granted I always learn something new from these sessions but what about the first timers and accidental DBA’s that have no idea where to start? The one place I noticed this trend the most was at SQL Saturday. While there are individual sessions that are aimed at beginner level I haven’t seen any tracks or actual dedicated sessions to starting SQL Server from scratch. For instance what are the basic tools of the trade? What’s SQL Server Management Studio? Who are the go to people for help?
Given this fact I would like to propose that organizers of SQL Saturday events consider putting in a dedicated track for Entry Level SQL folks. My suggestion is to call it SQL University but that’s just my take. My hometown user group, the Tampa SQL Server User Group will be organizing a SQL Saturday event in the coming months and I hope to get this program implemented in there. My hope is that individuals who are new to SQL Server, or would like to get into it, have a dedicated track in which they can feel comfortable going to without expectation of certain knowledge. In the meantime I will be doing a series of blog posts entitled SQL University which will cover the world of SQL Server from the ground up. In these posts I’ll cover basics such as tools to use, basic dba tasks etc. But that’s not all, I’d like to extend the help of my fellow bloggers on this project. If you’d like to become a SQL University professor hit me up at email@example.com. I’ll need professors in the different aspects such as administration, development and business intelligence. For this first semester of SQL-U I’d like to keep the classes at the 100-level. We’ll see how the project develops from there.
So, friends, what are your thoughts? Would you like to see something like this implemented? Do you think it will help raise awareness of organizations like PASS and bring in more attendees to our events? Let me hear your thoughts in the comments.
Update: WOW the response for this project has been really great! I now have a small pool of professors that will be helping out with this first semester. Due to this I’m closing the call for bloggers at this time. A big thank you to them (I’ll announce them soon) and a big thank you for all those willing to help out!
So the inaugural event for 24 Hours of SQL PASS has come and gone. In its wake its left hundreds of eager minds reeling from absolutely amazing content overload, bleary and blood-shot eyes around the globe and one worn-down rock star.
First off the staff at PASS and all of the presenters deserve a standing ovation for the amazing job they did putting this event together. From marketing the event across multiple platforms (i.e. Twitter, Facebook, Summit site) as well as adding a fun bonus add-on with having Tom LaRock (Blog), aka the SQLRockstar, do a full 24 hour co-broadcast via Ustream. While I wasn’t able to have the insanity fortitude of Tom and brave all 24 hours (did anyone else actually accomplish this insane feat?) I did manage to catch most of the ones that were of most interest to me. I’ll recap in order of sessions attended.
Hour 1 (8:00 PM EST) – 10 Big Ideas in Database Design by Louis Davidson (Blog|Twitter) and Paul Nielsen (Blog | Twitter)
I won’t lie, I pretty much missed the entirety of this session trying to get my desktop working so I could bring up the Live Meeting. The only thing I had working was the laptop running Tom’s Ustream feed and chat. Luckily this setup allowed me to listen to the session so I was in and out as far as paying attention while I tried to troubleshoot my desktop woes. It’s Dr. SQL and Paul Nielsen, can’t go wrong with these guys and from what I caught there was a lot of good information that people should pay attention to when developing. When this session becomes available on demand I’ll definitely be watching it.
Hour 2 (9:00 PM EST) – Using PowerShell to Get the Most Out of SQL Server by Allen White (Blog)
Powershell sessions always leave me feeling like less of a man for not knowing and using Powershell yet. TMI? Anywho, Allen did a great job showing some cool tips and tricks in showing how you can access and control different aspects of SQL Server via Powershell.
Hour 3 (10:00 PM EST) – Team Management Fundamentals by Kevin Kline ( Blog | Twitter )
This was one of my favorite sessions that I attended. Kevin’s topic was about how to effectively manage an IT team. Some of the stuff he mentioned is pretty universal but there are caveats when dealing with tech folks that he covered and covered well. Grab his slide deck and check it out, excellent presenter on a great topic. It’s funny because today Brent Ozar ( Blog | Twitter ) wrote up an article about management as well.
At this point I bowed out for the evening so I could grab some shut eye and get up early for Gail Shaw’s ( Blog ) Effective Indexing presentation at 6 am. Alas, I missed that one but got to the office early to catch the next one. I WILL be watching Gail’s presentation on demand when its available as effective indexing is something every DBA and developer needs to take the time and fully understand.
Hour 12 (7:00 am EST) – Reporting Services Inside and Out: The Things You Should Know by Simon Sabin (Blog|Twitter)
Reporting Services is one of those pieces of SQL Server that you look at it and think “damn I could do soooo many cool things with it”. You attend the webcasts, read the books, and if you’re anything like me you end up too busy to get to that awesome idea you had. Simon did a bang up job walking through SSRS and showing some cool tips and tricks with it. I especially liked the part where he created a report that dynamically changed pictures of either a check mark or an X depending on the result of the query on the column. I’ll definitely be re-watching that later on to try that out. Funny part of this session came when Simon had to excuse himself to take a call as he and his wife are expecting their baby to be born any day now. God speed Simon and hope your bundle of joy comes soon and healthy!
Hour 13 (8:00 am EST) – Query Performance Tuning 101 by Grant Fritchey (Blog|Twitter)
This was one of the most heavily attended sessions (about 450 people!) and for good reason, Grant is a fantastic presenter and his knowledge on the subject of performance tuning is second to none. I attended a session of Grant’s a couple of weeks ago and I got something new out of that. Same thing happened with this session. Grant’s book, SQL Server Query Performance Tuning Distilled, is on my list of must-buy books and if you have any interest in development or performance tuning it should be on yours as well. If you ever get a chance to attend any session by Grant I HIGHLY encourage you to do so. After that hour you’ll come away feeling like you want to re-write every bit of code within your grasp (and in some shops that probably wouldn’t be a bad idea!).
<insert a few hours of me doing my actual job here>
Hour 17 (12:00 pm EST) – Building a Better Blow by Steve Jones (Blog|Twitter)
Maybe its because I absolutely love Steve as a presenter (make sure to catch his weekly podcast, The Voice of the DBA), maybe its because I’ve taken up blogging in the last few months, whatever it was I have to say this one of my favorite sessions overall. Steve basically went over reasons why starting and maintaining a blog can be beneficial for you both personally and professionally. He also covered a topic of great importance in this realm which was basically DO NOT STEAL OTHER PEOPLE’S CONTENT!!! Seriously, it happens more than you think and if you get caught you just look really, really bad. Other highlights of this presentation were magically seeing my own profile come up in his slide deck as an example of a basic profile (thanks again Steve!) as well as watching Tom make Steve laugh on the air since apparently Steve had Tom’s broadcast up on another monitor.
<Insert a few more hours of meetings and doing work. Yeah, I know, you’re shocked>
Hour 24 (7:00 pm EST) – Embed Reporting Services into Your Applications by Jessica Moss (Blog|Twitter)
As I mentioned before Reporting Services is one of the those really cool features I wish I took more advantage of. Jessica is the SQL community’s resident expert on the topic and she does a great job of walking through the product and clearly explaining everything. This was a pretty cool session in which she showed the differences between the types of Reporting Services reports you can use and create. For instance did you know that in addition to .rdl files there are .rdlc files that are client side reports? Well up until last week I didn’t know that!
Overall I thought this was a fantastic event and I can’t thank PASS and the presenters enough. There were some glitches in the links for the Live Meeting links but thanks to the awesome community that problem was quickly handled via Twitter, chat rooms and blog posts. These events are mind-blowingly awesome in that you ALWAYS walk away with some new piece of knowledge and best of all…IT WAS FREE! The other thing about an event like this is that this is just a taste of what the annual PASS Summit can offer you. At the Summit not only do you get all of this mind-blowing content but you get to interact with presenters, you’re surrounded by the greatest experts from all over world, and you get to expand your social network thanks to all skills you got from the networking sessions AT the conference. So what are you waiting for? Print out your justification list, present it to your boss and get your rear to the PASS Summit. Make sure to register by September 15th to take advantage of the discounted pricing. After the 15th the price goes up $400.
Recently after one of my presentations a Twitter-buddy of mine, Argenis Fernandez ( Blog | Twitter ), showed me something interesting. By default when you create a new policy the against targets default says ‘Every Database’ (see screenshot below).
Well this is a tad misleading as it apparently means “every” in the sense that it will apply this policy against every USER database. This means if you want to ensure autoshrink is not enabled on your system database (master, msdb, model, tempdb), for example, applying this policy with this default target setting won’t work. So how do we create a new condition/target that allows us to run a policy against both user AND system databases? We’re going to create a new custom condition that allows us to look at both types of targets.
First click on the down arrow next to Every and go down to the bottom of the list and select ‘New condition…’
First you want to give this condition a new name. For this demo we’ll call it ‘Every database – User and System’. The next step is choosing the Facet as well as the property we want to look at. For this particular condition we want to use the ‘Database’ facet (which is the default facet selected). Next click on the box under Field and click the down arrow to view all of the properties available under that facet.
The field we want to select for this is the @IsSystemObject property. Once you select it, make sure your Operator value is set to ‘=’, then click on the field under Value. Once again, when you click on the field and click on the arrow you are given pre-set options. For this value select ‘True’.
Now that you’ve selected your first clause that states to apply to system object, we will create a second clause that applies to user objects as well. To start click on the next line where it says ‘Click here to add a clause’. When you click on it you’ll notice you get a new row to be able to create a new expression. For the first column (AndOr) we want to select ‘OR’. This is important because if you select AND in this instance, you’ll never return a valid entry since an object is either a system object OR a user object, never both. Next select the @IsSystemObject again from Field value and finally set the value to FALSE. Your Expression should now look like this:
Click OK and you should now see your new ‘Every database – User and System’ in the Against Targets box. Click OK to close your policy. To test it apply your policy against your database via your Central Management Server (CMS). To do that drill down to your server, right-click the database click ‘Evaluate Policies…’
From the Evaluate Policies box click on the ellipses box to select your Source. Your source is where your policies are located. With PBM you can either select individual policies (XML file) or you can select a SQL 2008 Server that has the policy you want. In my case I am selecting a server that contains the policies so all of the policies on that server will appear in my list. Select the policy we modified with the new target.
To verify we’re using the right target click on the policy name (in this case ‘Database Auto Shrink’). This will open the policy itself and you can verify that the correct target is in place. You should see your ‘Every database – User and System’ in the Targets window. Click Close to close the policy. With your policy checked click on the Evaluate button to proceed. The policy will then run and show you your results. In the target details box you should see your policy has run against all your databases, both user and system.
There is also a way to create this through a script. I created this particular via the SSMS gui but if you want to export it you can let SSMS create the T-SQL Script for you and share the code. To do this right-click on the condition in SSMS, Script Condition as, CREATE TO. To have it go directly to creating the .SQL script file for you select ‘File…’ otherwise lets select the ‘New Query Editor Window’ so we can see our result.
For this particular policy you should see something similar to this be output to SSMS:
<span class="kwrd">EXEC</span>msdb.dbo.sp_syspolicy_add_condition@name=N<span class="str">'System and User'</span>,@description=N<span class="str">'Allows you to select both user databases as well as all system databases.'</span>,@facet=N<span class="str">'Database'</span>,@expression=N<span class="str">'<Operator>
And that’s it! You now have your T-SQL Code to create your new condition on other SQL 2008 Servers. Note of caution, however, be careful about how you use this as messing with system databases can be disasterous if you’re not careful.
Chris Shaw ( Blog | Twitter ) started another great web chainpost. He tagged Brent Ozar, Brent tagged Thomas LaRock and Tom tagged me. This particular quiz is a two-part question and here are my responses. Excuse my lack of wit and charm. It’s late, my caffeine supply is running low and my cat is eyeballing me in a most peculiar fashion.
Do you feel that you have a reliable SAN solution? If so, what’s the secret?
It’s hard for me to answer this one given that just a few weeks ago our data center (SAN included) came crashing down hard. Now given that the problem was a faulty generator test and not the SAN itself that was the problem I can’t really place blame there. Honestly I can’t say anything really bad about our SAN. Tons of disk space, tons of cache, it does what its supposed to do. We’re also in the middle of finding a replacement for a SAN administrator so what SAN solutions we have in place now could radically change in the coming months. As far as secrets go I’d say you just need to make sure you have an open line of communication with your SAN administrator. They have no idea what’s going on in your world and you have no idea what’s going in theirs. Clear communication of needs need to be there as a SAN admin worth his salt is going to know what they need to do on their end to make sure you get the best performance on your end (i.e. proper RAID levels for your LUNs depending on needs, I/O throughput, etc.).
Explain Database Mirroring in layman’s terms
Everyone else seems to be giving off-the-wall answers to this so I’ll give it a go as well. Not going to lie, took me a good portion of my drive to Melbourne last week to finally come up with an example.
Think of clustering as a conjoined twin. You’re talking to the same body. Both heads can hear the conversation but ultimately the two are stuck together because they have to share the same base trunk. Now if you were to punch one twin in the face and knock him out you’d still be able to talk to the other head but you’re still lugging around that base. Now, imagine a set of regular twins (non-conjoined). This is your database mirroring in that you have two separate entities. You knock one out but the other is still chugging along just fine. Only difference being that the location of the second one doesn’t really matter because he doesn’t have a shared trunk to deal with. I’m sorry if that explanation sucks, if you’re bored check out the whitepaper written by someone who doesn’t have a fascination for using genetic defects to compare feature sets. Ok time for me to tag a couple of unwilling victims fellow bloggers: