Rule #2: Have a tested Backup and Recovery Plan I’m sure no one out there isn’t doing a backup on their database server at some interval compatible with the nature of their data. If you’re updating your data weekly, weekly is fine; if you’re updating every minute of every day, you need to backup more…
Beginning SQL Server 2005 Programming
I was looking for a good reference book to use in creating training lessons for the site. I have to say this book is great for that. Lucky for me, it’s not as good at actually teaching you. I’d say it does a little better than the Books On Line, but not by a lot….
The DBA’s Rules
I don’t know if you’re a fan of NCIS, but for those of you who aren’t let me give you a little back story. Gibbs is the leader of an investigative team and he has a set of rules he teaches his team members in order to help make them better at their jobs. He…
Determine the Space Used by Tables
Eventually you’ll be faced with running out of space on a SQL server. Usually, before you get more drive space, you’re asked to find out if you can get rid of any information you’re holding onto in the server. You come up with a list of tables in databases that you feel you could remove…
Inter-Database Queries
I’ve had this question come up a few times now. “How do I copy data from one database to another?” It’s after getting a question like that, I explain fully qualified database object names. That’s a mouthful! Basically it’s a fancy way of saying the “full name” of a database object, like a table or…
SQL 201 — CREATE PROCEDURE
Now that you have the basics of SQL, I think it’s time to learn something a bit more involved. If you need to accomplish a task within SQL you will run a series of T-SQL statements. If you want to run those same steps over and over again, you could save them to a file,…
SQL101-Homework Assignment #6 Answer Key
Here are the answers for homework #6. Let me know if you have any questions! USE AdventureWorks GO 1. How many rows are there in Sales.SalesOrderHeader? SELECT COUNT(*) FROM Sales.SalesOrderHeader 2. How many Rows are there in Sales.SalesOrderDetail, that are also in Sales.SalesOrderHeader (SalesOrderID is the common/shared column)? SELECT COUNT(*) FROM Sales.SalesOrderDetail sod INNER JOIN…
SQL101-Homework Assignment #6
We’re starting to cover some more difficult subjects in these homework problems. Please let me know if you need any help! 1. How many rows are there in Sales.SalesOrderHeader? 2. How many Rows are there in Sales.SalesOrderDetail, that are also in Sales.SalesOrderHeader (SalesOrderID is the common/shared column)? 3. How many sales orders (sales.salesOrderHeader) were made…
SQL 201 – CREATE TABLE
CREATE TABLE I’ve showed you how to get data out of a table, put data in, change it, and delete it. But I haven’t showed you how to create your own table….until now. CREATE TABLE tableName ( columnName <datatype> ) This statement is pretty straightforward, you have to choose the name of the table, and…
SQL101-Homework Assignment #5 Answer Key
These answers have been updated to work with Adventureworks on 2008R2. 1. Write an UPDATE query that would set your middle name, for only your record by personID. (if there is no record for you, add it in first, then show me the update to set your middle name.) UPDATE Person.Contact SET MiddleName = ‘Dwight’…