Write, format, analyze, and refactor SQL fast with SQL Prompt
Writing SQL is 50% faster with SQL Prompt. Your SQL code can be formatted just the way you like it, you can create and share snippets with your team, and with code analysis you get suggestions to improve your SQL as you type. Download your free trial
How to track every change to your SQL Server database
See who’s changing your database, alongside affected objects, date, time, and reason for the change with SQL Source Control. Get a full change history in your source control system. Learn more
The UNPIVOT operator does just the opposite of the PIVOT operator, which we looked at in the previous level. By using the PIVOT operator we can take multiple rows of data and create as single row as output. The UNPIVOT operator will take values from a single row and will create multiple rows. Microsoft introduced the UNPIVOT operator when they rolled out SQL Server 2005. In this level I will be showing you different examples of how to use the UNPIVOT operator. More »
Every day, out in the various online forums devoted to SQL Server, and on Twitter, the same types of questions come up repeatedly: Why is this query running slowly? Why is SQL Server ignoring my index? Why does this query run quickly sometimes and slowly at others? My response is the same in each case: have you looked at the execution plan? More »
There are four SQL Prompt snippet placeholders that are all about selection and copying of text. These placeholders are very handy if, for example, you have two blocks of code that need to be part of a snippet. One part you hold on the clipboard, and the other part is a block of snippet text, selected using the $SELECTEDTEXT$ placeholder. More »
This is quite a new feature (currently in preview) but an important one where we now have the ability to... More »
Question of the Day
Today's Question (by Steve Jones):
I have a dataframe called "sacks" that looks like this:
# A tibble: 5 x 5
Rank Player Sk Years Tm
1 1 "Bruce Smith+\\SmitBr00" 200 1985-2003 2TM
2 2 "Reggie White+\\WhitRe00" 198 1985-2000 3TM
3 3 "Kevin Greene+\\GreeKe00" 160 1985-1999 4TM
4 4 "Julius Peppers\\PeppJu99" 154 2002-2017 3TM
5 5 "Chris Doleman+\\DoleCh00" 150 1985-1999 3TM
I have a second data frame that looks like this:
# A tibble: 5 x 5
Rank Player Sk Years Tm
1 6 "Michael Strahan+\\StraMi02" 142 1993-2007 nyg
2 7 "Jason Taylor+\\TaylJa03" 140 1997-2011 3TM
3 8 "DeMarcus Ware\\WareDe99" 138 2005-2016 2TM
4 9 "Richard Dent+\\DentRi00" 138 1983-1997 4TM
5 NA "John Randle+\\RandJo00" 138 1990-2003 2TM
If I want to combine these into sacks1to10 as a single data frame with the same number of columns which command do I use?
Think you know the answer? Click here, and find out if you are right.
We keep track of your score to give you bragging rights against your peers.
This question is worth
1 point in this category: R Language.
We'd love to give you credit for your own question and answer.
To submit a QOTD, simply log in to the
Yesterday's Question of the Day
(by Mohammed Arshad):
When an index is rebuilt, does the fill factor apply permanently to the index until the next index rebuild?
The answer is no.
When an index is rebuilt, SQL server re-arranges the index pages as per the fill factor provided and fills only that amount of space on each page. If no fill factor is set, the pages are filled. But the real catch is, SQL Server doesn't doesn't leave the free space configured in the fill factor for new pages that are required.
For example, if there are 80 pages in an index with fill factor 100% and it is rebuilt with a fill factor of 80%, SQL Server re-arranges all the 80 pages with 20% free space on each resulting in more total pages because now it has to leave 20% free space on all of them.
When a new transaction requires a new page, SQL Server doesn't apply the 80% fill factor for new pages allocated.
This newsletter was sent to you because you signed up at SQLServerCentral.com.
Feel free to forward this to any colleagues that you think might be interested.
If you have received this email from a colleague, you can register to receive it here.