Louis's profileThe SQL Doctor is In (Re...PhotosBlogListsMore ![]() | Help |
|
|
May 20 Sorting and case sensitive collationsThis is an addition to my book, on page 255, to the end of the section on collation (before the statement that I won't delve any deeper into collations, of course :)), I want to add the following bit of information about collations and how they affect sorting and searching. You can download the entire addendum with source code from the: Sort and Searching One of the more confusing parts of collation is how they affect the ordering of data when sorted and how that can affect other operations like the LIKE operator. When it comes to case insensitive collations, it is pretty clear, data is sorted as if 'A' and 'a', are the same character. The other common situation is accent insensitivity where 'a' and 'ấ' appear as the same character. When you are using a case and accent insensitive collation there will be no guarantee when sorting data that either of these characters would come first in the list. The great part about this is that when you search for where like '%A%', you know that you will get back: aardvark, Abel, Penấ with no worries. In some situations, this is not desirable to have this be the case, and you set up a column, table, or database to be case sensitive and accent sensitive. This is where sometimes you can get confused when using between, like, or other range type queries on characters. As an example, let me create the following table and seed it with some characters: create table dbo.TestSorting select value All rows are returned, as expected: value The problem comes in when you want to do a case sensitive search. You choose a case sensitive collation, and either use it in the WHERE clause or in your table declaration, and: select value This returns what seems a confusing set: value Everyone who does this the first time thinks "Why?" And I did too (in fact it was why I wrote this section of the book!) The key is to kook at how the values sort in this collation: select value value Case sensitive sorts things aAbBcC, not, as most of us programmers expect intuitively: ABCabc. That is actually how a binary collation works, since it sorts based on the ASCII or Unicode value of the character. Using a binary collation would work, but then you lose the ability to include the special characters in your search which is given to you by using accent insensitivity. Instead, you can simply use a LIKE such as this: select value This returns only the capital letters including the accented capital letter I included. value It is a good idea to take a look at the sorting of data when you choose a collation to make sure it is clear to you how data will be sorted. First in the data you have in your table, like this, if you want to see how it will sort in a binary collation: select value value
;with digits (i) as( select 1 as i union all select 2 as i union all select 3 union all Crossposted to http://sqlblog.com/blogs/louis_davidson/default.aspx March 22 Wow, I never noticed this review...One of the things I promised when I published my last book was to answer my critics. To take the good and take the bad and fix stuff. So when I first read this review on a popular book sales site that rhymes with Carnes and Shobles, it was positive, but tonight when I (for some reason) went to look at rankings there, I noticed that it was kind a strange. To be honest, my book title includes the word "Optimization". And it is not a lie, my goal is to help the reader start out straight and end up with an optimized database. Fine. However, this review states that my book is "An extensive Database optimization book." It goes on to state that "This book completely demystifies a number of SQL tuning concepts." I don't know if this person read the book (I hope not, truthfully) as I don't know that I do that. The book is about designing databases first and foremost, with a coverage of optimization topics related to implementing databases that you have designed. Admittedly, some of what the review says is true: "This book provides a superb overview of the various performance topics" (I am going to go ahead and accept the generous "superb" thing.) But I don't "drill down down deep enough into the concepts to give you the insights necessary to tackle thorny performance problems with multiple causes." I leave that to Kalen and others to do. My goal is to stop you from digging the hole too deep in the first place. And the part that says: "The book delivers in-depth information on indexing, locking, the optimizer and many other topics in a very readable format." Well, I have been told that it is in a readable format, and there is broad overview information about indexing and locking, but not a tremendous amount of depth. Again, check Kalen's books for that. What I find strange is the purpose of this review. If the book company paid for it, they didn't get their money's worth. At least those phony movie reviewers appeared to have seen the movie in question. I can't think of any other reason to publish a positive review of a book you didn't read (I have seen plenty of bad reviews by people who had clearly not read a book, but never the other way around.) So there you have it, a negative review of a positive review of my own book. But I did promise. February 09 I just did something that felt wrong...And no, it doesn't have anything to do with a number two pencil and an ear. No, in this case a person emailed me and said "I am interested in your book '*Pro SQL Server 2005 Database Design and Now, here is where the little marketing/sales devil guy sits on your shoulder and says: "Hey, you. Sell him a book, he will like it, even if it isn't exactly what he wants" and this little tech guy angel sits on the other shoulder and goes "You know there are better books out there for him to start with." Now perhaps these two little apparitions wouldn't have appeared if I kept sharp things out of my ear, but the fact is, it is never natural to tell people to purchase something that doesn't benefit you, particularly when you have a direct interest involved. This was part of the reason I was a terrible Radio Shack employee around 18 years ago. I liked a lot of their products, and it was a cool place, but all of the big ticket items that would have actually made it lucrative to work there were inferior to products you could get elsewhere. In this case, I know for sure that this person would be better off starting somewhere else, though I would like to see his second or third book be mine, as I am very keen to push the "why normalize"/"why use constraints/triggers" agenda. So, what did I do? Well, clearly if I had listened to marketing guy I wouldn't be sitting here proudly admitting that I told the guy to buy my book would I? No, in the end what I hope is that one day after he reads Itzik's and Bob's books, he comes back and purchases mine. Then maybe he will tell others, and they will tell others, and then I wake up and mysteriously there sits a can of pencils, but luckily they are number 3H, and not 2. Crisis averted. December 27 Contest is over!Thankfully. I didn't have a lot of guesses, but I had a couple of folks with the right answer, and a lot of friends try to guess (and one who actually got it) The winners should be quite proud of themselves (and they get some goodies to boot.) Ok, so the answer was found on page 355. The value of the cookie, when casted to a varchar value reads: "Be sure to drink your Ovaltine. " a line from the movie "A Christmas Story" when the lead character uses his Little Orphan Annie decoder pin to reveal this message, much to his disgust. I got the idea for the hidden message watching the movie last Christmas while working on the book :) Well, I hope that my contest hasn't bored you, bugged you, annoyed you, cheesed you off (unless crackers were involved) or any other thing that might be even vaguely unpleasant :) I just wanted to add a bit of fun to a fairly dry topic, especially in a way that was not intrusive. If it did (see prior list) then bah! humbug! to you too. And be sure to stay away from the Red Ryder pump action BB gun. You will likely shoot your eye out! Either way, thank you from drsql.org, myself, etc and have a super dandy new year! I hope you got as much out of the book, blog, and website as I did writing this stuff. I feel blessed to have the ability to assist as many of you has I possibly can. As always, feel free to email me at drsql@hotmail.com with comments, requests, etc. December 22 The last clue...And then I give up. If you can't get it from the final two clues alone then you basically don't want to win :) select cast(0x486F706566756C6C7920796F752073686F756C64206E6F74206E656564206D6F726520636C756573207468616E2074686973 as varchar(60)) I will try to post the answer on the 27th, if I have Internet (going on vacation!) So, hope you enjoyed my contest, and have a Merry Christmas and a Happy New Year. See you next year with my recap of this year and my next year's resolutions. Book addendum modificationsI (and a few diligent readers, who really pay attention) found five things that I am going to add to the book today, before the holidays. I got really crunched for time near the end of the year, so I didn't get as much of this done as I would like to have. 1. A bug in some of the code in chapter 4. 2. An incorrect index on a diagram in chapter 5. 3. A new tip about heaps, and an extra word removed from a paragraph in Chapter 8. 4. Much better information about the date datatype, particularly with regards to standard date formats in Appendix B 5. An issue with a query of the sys.schemas view. in chapter 5. More to come next year, as I am going to have to catch up some of the book to match SP2, I am thinking. Download the addendum here: http://drsql.org/Documents/Pro_SQL_Server_2005_Dat abase_Design_and_Optimization_Addendum.zip December 20 Clues.. Clues..Ok, so only a few more days left in my contest, and so few answers given. So if you own a copy of the book, and can find the message using the clues found here: http://drsql.org/hiddenMessageContest.aspx I have stepped up the clues and have added daily clues for this week.
You are still in the running for the Bundle of Apress books (Pro SQL Server 2005, Pro SQL Server 2005 Assemblies, Pro SQL Server 2005 Reporting Services, SQL Server 2005 T-SQL Recipes, as well as another copy of Pro SQL Server 2005 Database Design and Optimization to give to a friend, assuming you used your own copy to win the contest with!) I know if I wasn't running the contest, I would be looking.
Plus, I have ten Apress T-Shirts to give, and every entrant, no matter how bad the answer try, gets a free eBook. Not too shabby.
So just by sending email to contest@drsql.org, with "hidden" in the subject. Good luck! December 03 Contest Clue for December 3Okay, so the contest (which I have gotten very little feedback on yet, other than a death threat or two for the very cryptic clues I have been dishing out...) comes to an end in a few weeks now, so the next 4 clues are going to take someone to the prize, so start hunting! 3-Dec On December 25, Santa delivers toys to good boys and girls. In our country, we left him a cookie as a snack so he would bring us a Red Ryder BB Gun. Of course, our parents told us that we would shoot our eye out, but we knew better. Most of what you need to find the answer is right there in the clue. So if you have read the book, think back to see if one of the words I used rings a bell... So click here: http://drsql.org/hiddenMessageContest.aspx, check the rules, prizes, and then send your email to contest@drsql.org. Good luck! September 18 New blog strategySomething I have been considering for a good while has been a change in strategy for this blog. Once I found my blog listed on the SQLBlog.com's Blog Roller, I have tensed up and stop posting goofy stuff, device reviews, movie reviews etc, because I didn't want to muddy up their blog roller. I actually really dig that feed, plus the main site feed. They are both amongst my favorite feeds on the internet.
So when the opportunity came to join this group of bloggers: Adam Machanic, Peter DeBetta's , Hugo Kornelis, Kalen Delaney, Rick Heiges, Andrew Kelly, and Kevin Kline (and another whose only moniker is Mystery Blogger,) no way could I turn that down (all of these guys are my heroes :).
So in the future, I will be posting to this site everything. All of my ramblings, all of my goofyness, and all of my rants, plus my more technical articles. On that blog, I will crosspost all of the more "serious" pieces. Certainly only things that pertain to SQL Server. Here I will continue to post about publishing, writing, upcoming projects, etc. The new URL will be: http://sqlblog.com/blogs/louis_davidson
Also, I will continue to maintain the blog listing over on drsql.org. August 01 Here we go again (new URL)Ok, they have promised us that this will be the last change, but the new URL is http://drsql.spaces.live.com and the RSS feed url is : http://drsql.spaces.live.com/feed.rss. I am instantly liking the new look of the site and I hope it lets me keep going with this blog here. If you have opinions on the new site, have problems accessing, or just want to tell me that I have won the lottery please email me at drsql@hotmail.com. June 29 Simple TalkIf you haven't seen it yet, the Simple Talk (www.simple-talk.com) site is now active. And let me be the first one to say (on this blog anyhow :) that it is an impressively designed site. Very polished looking indeed. Tony Davis (the editor) has done a very nice job pulling this together.
So go check it out! June 13 They changed the urls for spacesThe new address is: http://drsql.spaces.msn.com and the the new RSS feed is: http://drsql.spaces.msn.com/feed.rss. Hopefully this will be seamless for everyone and your RSS tool will handle the redirect and it won't be an issue. However, if you could change to the new address, it would probably be safer (I know you wouldn't want to miss even a single blog, right?)
MSN has promised that this won't be an issue and that the old addresses will continue to work, but it does raise the question "if the old method would work, why not just stick with it?" Apparently it was all part of a plan to handle the incredible number of users they have (over 100 Million!)http://thespacecraft.spaces.msn.com/blog/cns!8AA773FE0A12B9E3!12745.entry. Oh well, I will try to change it in my book for the second printing :) May 21 My new website/Office Live plug...Part of the reason I started blogging was to accumulate a body of artcles/code snippets to use when I need something. I work on four different computers on most days (even more when I have to work directly on a server) and it was a pain trying to find some place where I could keep this stuff on a corporate network share that I could get to from any of four different domains/domain accounts. Plus, I hope that a few of you like the stuff that I write and use it also. I have no designs to be the only place on the web to get information, but beyond two or three articles a week with some SQL insight (and a few just for fun), I want to be useful on an ongoing basis at least to myself.
I am, and have always been an F1 programmer. Syntax for the REPLACE function? <F1> Index hints? <F1>. When I am answering quesitons in the MSDN Forums, it is about 30% hitting the BOL to determine some syntax, or concept. Every time I write a book, article, etc, the reason I do so is simple. So I will have it for later use. I use my book as a reference to get some concepts over and over again as I just don't have an elephant's memory (perhaps one that had a lobatomy, but that really isn't much help.)
I had been tossing around the idea of a website for over a year, especially as a companion to the book, So when I got an email from Microsoft Office Live saying that they had web hosting (for FREE), well Bob's your uncle I just had to do it. I am glad I did it now, because it allows me to have a two phase system. The blog, which I am happy with and will remain the "live" part of my website. I will continue to publish here, pretty much everything I publish/link to there first. For example, I have four book reviews, two of them have been posted here, the other is Kalen's Inside SQL Server 2000, and if you don't already have that book and you read my site then you probably should. I wrote a chapter in the other so I won't review it (the book is good though.)
The site is (ta da) DrSQL.org. It has a few pages, but there are two that I hope you will find ultra useful.
1. The home page. On here, I have my favorite section, the Frequent Linkers. These are posts I have made and other sites that I go to regularly (for example, I blogged a query to get server activity. I found myself going to the site on occasion to get this post, and it was harder and harder to reach as more posts stacked up)
The home page also has information, contest stuff, interviews, downloads etc. that go with any recent stuff I have done. A proper downloads page is in the works.
2. The SQL Blog Index. I have taken all of my SQL related posts and linked them in there if I (or you) ever think, didn't I (or Louis) ever write something on the $rowguid keyword? Why yes I (or he) did: $identity and $rowguid in the SELECT clause (2005). At the very least it might be useful to newbies who want to look up a feature.
I have also created a mobile version of the index for you if you are so inclined. I carry a PocketPC phone and I often read a few particular sites because they have mobile friendly sites. Since my articles are on a site that is very mobile friendly (msn.spaces.com/drsql) this was very easy for me to do.
Let me know what you think! April 04 DoneThis will be my last post in the Publishing category pertaining to the Pro SQL Server 2005 Database Design and Optimization. I stuck a fork in it just over an hour ago. I emailed my code samples to the publishing company, for which I have been promised the final a small token of their appreciation (which they are contractually obligated to do of course :)
Now, to keep these "tokens" coming, I need you to go out and buy a copy of the book. Give a copy to your wife, husband, child, use it to line the bird cage but just buy it. Not that old red WROX book with my mug shot on it (with my head tilted to the side) but the new one with the much smaller picture on it straight up and down. Straight up and down, I say. It is going to be around 600 pages after the index is added maybe a little more or less, but it will be well worth the $600 they are charging. Wait, it is only $60 retail? 38 bucks with free shipping at Amazon, what are they thinking?
All kidding aside, in the near future I hope to announce a new book that I am working to have written, which I am hopefully going to be the lead editor on. It was an idea for a book based on the fact that I knew enough to be dangerous, but not nearly enough to be an authority. It is a really exciting concept that I think will be really useful on any database professional's desk.
Do you have an idea for a book or article that you want to write or see written? Perhaps because you are an expert, but even if you just wish you were an expert. Email me at drsql@hotmail.com and let me know your idea. I make no promises, either expressed or implied of anything. But I will be happy to take your idea and use it as my own (kidding!) Truthfully, if I tried to spend much more time working on stuff like this I would likely be single or unemployed, and if you have heard me say it once, you have heard it twice. Authoring doesn't pay diddley. I think of it as a learning experience that occasionally gets me goodies. Of course, if I consider how valuable the learning experience has been well...it pays greatly.
In the future all talk of the new book or websites will be in the Publishing category, but posts about the design book will go here under the DesignBook category and simultaneously on my Amazon Connect page. If you review my book on Amazon, I am planning on replying to your critique as well as doing anything I can to help make you satisfied. April 01 Big News!FOR IMMEDIATE RELEASE:
April 1, 2005 Disneey Productions to film movie version of technical book
ORLANDO, FL — With the forthcoming release of his new book, Louis completes his pandemic trilogy: SQL Server Design: consisting of titles: Professional SQL Server 2000 Database Design, Pro SQL Server 2000 Database Design and Opimization, and now Pro SQL Server 2005 Database Design and Optimization. With the final book completed, he is finally going to realize his ultimate dream, filming the movie version of the 2000 book.
The plot of the book revolves around a simple database designer (scheduled to be played by Ron Palillo) as he travels though the exciting world of relational database design. From the first interaction with the somewhat crabby user, to the interrogation of the records clerk, to the purchasing of snacks at a local convienience store, this epic drama will have you in stitches. See the inside of cubicle after cubicle as our hero grows from nerd to slightly older, slightly fatter nerd.
R2D2 will play the part of a database server, while Peter Weller will appear as the ultimate user interface death machine. Louis and the rest of the cast will appear on Monday, April 31 on the Oprah show, as well as several other national talk shows during the month of Moy. Oprah, speaking on condition of anonymity claimed that, "there is not a show scheduled for April 31st...security!" Security, wow, could there be a more emphatic way to say "good idea?" I think not. (Check your local listings for when the show will air in your time zone.)
When asked if this was a risky venture to film a movie version of a technical book, an unnamed Disneey representative shrugged his shoulders and said: "What?" Yet another said, "who are you? Get out of my back yard." These accolades and several others that contain language that is unfit to print are strong evidence that Disneey is completely behind the idea that is years ahead of its time. The movie is set to begin filming sometime in middle of 2007, with an estimated release sometime after the core of the earth cools.
March 29 End of project burn outI have so many topics I want to write about but less energy than sleepy sloth. I finally heard these words tonight from my editor: "I will email you again to let you know that the book has shipped" and from another editor: "release your final payment upon receipt" in regards to my final source code package for download. I have those files ready to send.
Now I just have to find the energy :) I have about four things that I think I forgot to put in the book that I will be putting here on the blog as well as staring a PDF version that you can download with the new stuff. No matter how many pages a book is (this one weighs in at 600 pages) there is always something that you forget, wish was better, just got plain wrong, etc.
This time I am not going to say who cares to this forgotten material. After the first book I just said "bah!" to the whole process and went and played video games. (Don't get me wrong, I am still going to play video games finally, but ) this website is listed in four or five places in the book as a place to come and get stuff pertaining to the book. I built in motivation for myself (I may come to hate myself later, but right now it seems like a good idea :)
I will add a list in a month or less that has links to the files that have the additional information. I am also thinking about taking all of the SQL related posts and packaging them up as a download also. Let me know what you think...
March 21 There are just tons of differences between database platformsI was doing the final PDF edit on the Database Interopability chapter (written by the illustrious Kevin Kline) and it is just nuts how different the different database platforms are. He covers the basic differences between DB2, My SQL, Oracle, and SQL Server. After reading the first bits of the chapter I almost felt like the different platforms aren't even the same thing. But he covers the differences and does a great job.
I am really glad that the product that I work on will only need to work on SQL Server.
On the really good side, this was my last chapter to go through final edit on, and all that is left now are questions about things I have done or the occasional image redraw. For example, down in the photos of this blog I have uploaded a progression of images that have been used for a certain process oriented set of pictures. The first on was scrubbed because it wasn't of good enough quality. I nixed the second one because the person looked like a salesperson or manager type (nothing wrong with either (necessarily :) but just not a programmer) and the third is where we might stop.
My only concern with this picture is the tie. Do programmers wear ties? I hope not. March 15 The cover is finalized!I received the cover of the book the other day from the publishers with permission to publish it. It is really exciting when you start to realize that the book will not only be done in the next day or two, but it will be on book shelves in middle April. I have a few fun things I plan to do around the launch of the book personally (like the hidden phrase scavenger hunt) as well as a couple of things sponsored by the publisher.
I also want to publicly thank Kevin Kline and Kurt Windisch for filling in the gaps for me on a few subjects that I just didn't know well enough to publish on, and probably never will. Kurt wrote several large sections in a couple of chapters about CLR programming, and Kevin wrote a chapter on building cross-platform databases.
Stay tuned in for more information... March 13 No more ads...MSN has allowed those of us who pay for their services to remove ads from our Spaces site, which I have graciously accepted! So if you come here directly and don't use a RSS Reader (the best way to go, don'tcha know) this is one less thing to waste your bandwidth on.
March 09 Word Tip - Browse By Object I have written nearly 2000 pages of text in Word, but I still don't consider myself a major power user. The 2003 version of Word has really been great this past year, much better than the version I used back in 2001 (I think it was 2000, but it might have been XP.) I had quite a few corrupted documents back then, but not even once did I have that problem this time (I can say this because I am finished with the Word part of the book. The remaining work will be done in Acrobat.)
When I was attending the Microsoft event the other day, one of the interesting things I learned had nothing to do with SQL Server or CRM, rather it was about my old friend Word. Very often when reviewing a document I have to scroll around in the document to change a section. Sections are all set up by a piece of text in one level of Header style.
I have noticed the little extra scroll bars at the bottom of Word (double arrow up, a little circle, and double down arrows (see the pictures down below)) for a very long time, but frankly I never really messed with them. They allow you to scroll by different amounts page, section, comment, edits, etc. There are two really useful ones that I find pretty useful:
Just figured that if you use Word for writing articles/papers and you primarily work with SQL like I do, you probably don't know all of the features either, and this is a very useful one. So you can click through to each of the heading entries |
|
|