Here’s another set of questions for you to practice on. As always, if you have any questions, let me know and I’ll help you. UPDATE 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…
SQL101-Homework Assignment #4 Answer Key
Here are my solutions updated to work with AdventureWorks on 2008R2. 1. Write a DELETE query that would remove a record from person.contact by contactID, pick a contactID that does not exist in person.contact. DELETE FROM Person.Contact WHERE ContactID = -1 2. Write a DELETE query that would remove a record from person.contact by first…
SQL101-Homework Assignment #4
Here are some more practice problems. This time you’re going to practice using DELETE. 1. Write a DELETE query that would remove a record from person.contact by contactID, pick a contactID that does not exist in person.contact. 2. Write a DELETE query that would remove a record from person.contact by first and last name. 3….
SQL 101 – DELETE
It looks like I’m getting close to the end of my 101 series. After I show you how to remove data from tables, the last topic I plan to cover is creating tables. It’s been quite a journey, collecting all this knowledge and putting it out there for you. I had hoped to get some…
SQL 101 – TRANSACTION
As I mentioned in my previous post, before you move on to more difficult topics I need to share with you what a TRANSACTION is, and how to use them. By now I’m sure you’ve seen t-SQL on tutorials. The T stands for transactional. If you don’t know what a TRANSACTION is, that’s pretty meaningless,…
SQL101-Homework Assignment #3 Answer Key
Here are the answers to the previous practice problems. 1. Write the query that would put the full name (as much of it as you know) of your favorite Star Wars character into the Person.Contact table. Use the title field to identify them as ‘SWChar’. You can use the INSERT that uses VALUES or SELECT…
SQL101-Homework Assignment #3
1. Write the query that would put the full name (as much of it as you know) of your favorite Star Wars character into the Person.Contact table. Use the title field to identify them as ‘SWChar’. You can use the INSERT that uses VALUES or SELECT to do this, again, extra points if you show…
SQL 101 – INSERT
In all the previous articles I’ve written on SQL I’ve showed you how to get data out of the database. Now, we’re switching gears. I’m going to show you how to put data into the database. The command to put data into the database is INSERT. There are four main ways to use this command,…
SQL 101 – UPDATE
Previously, I showed you how to get new information into a SQL database. This time I’ll show you how to make changes to that data, once it’s in there. The basic structure of the change command is: UPDATE tableName SET columnName = ‘value’ WHERE <some test> I can’t tell you how important that WHERE clause…
Comparing Query Performance
A significant portion of your time as a database programmer or administrator will be to improve the performance of queries. While there are several benchmarks you can compare two or more queries, the actual comparision of the two queries can lean you do make false assumptions. When you run a query, data and execution plans…