{"id":82071,"date":"2009-12-23T20:07:41","date_gmt":"2009-12-23T20:07:41","guid":{"rendered":"https:\/\/www.webstaging.red-gate.com\/simple-talk\/?p=73293"},"modified":"2018-12-12T12:18:12","modified_gmt":"2018-12-12T12:18:12","slug":"seasons-greetings-sql","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/seasons-greetings-sql\/","title":{"rendered":"Seasons Greetings.SQL"},"content":{"rendered":"<p>My family used to send out Christmas cards with a yearly report of &quot;where we are from whenst we came from&quot; report, but some years we depressed people, but too often it sounded like bragging. This year I could neither brag nor depress, for it has been a pretty even Steven kind of year. Some medical stuff, but had a really good year SQLwise. Kept the MVP, wrote some good blogs that will make up a chapter of my next design book, and finally hit a nice stride when speaking (big thanks to Paul Nielsen, as speaking with him has really helped me see what I did right (and wrong!)<\/p>\n<p>But here at the end of the year, it is definitely the custom to send out cards to people. As a guy, I am not really into the whole \u201cphysical\u201d card thing, but I like writing SQL. So I figured I would combine the greeting thing with the SQL thing. The following script, when run, will, Mad Libs style, spit out a personalized holiday message from me to you. A little personal, a little SQL.<\/p>\n<p>If you are not so equipped to run the script, email me at <a href=\"http:\/\/mailto:louis@drsql.org\">louis@drsql.org<\/a> and I will translate. Of course, I am more than happy to take any other types of messages there too (other than ones that pertain to my lottery winnings or any sort of personal products to enhance my life by emptying wallet. Those are right out.) For those who lack the desire to spend the effort, Merry Christmas, Happy New Year, etc. I love this community of SQL folks as a really interesting extended family (frankly I see a lot of you more than my family at various events \ud83d\ude42 But hey, if I was gonna say much more then the following SQL would be a waste of time, huh.<\/p>\n<p>I will note, if you say you don\u2019t celebrate Christmas, but you do believe in Santa Claus, you won\u2019t cause your computer to burn up with a paradox, but I did default it to a lack of belief in Santa, cause frankly, I figure the largest contingency of my readers are the ones who have to buy the gifts, not wonder where they came from \ud83d\ude42<\/p>\n<p>See you in a week with my SQL New Year\u2019s Resolutions!<\/p>\n<p>declare @name varchar(30)     <br \/>declare @celebrateChristmasFlag bit      <br \/>declare @presentYouWant varchar(100)      <br \/>declare @believeInSantaFlag bit <\/p>\n<p>set @name = &#8216;Friend&#8217; &#8211;&lt;Your name here     <br \/>set @celebrateChristmasFlag = 1      <br \/>set @presentYouWant = &#8216;Quad Core Netbook with eternal battery&#8217;      <br \/>set @believeInSantaFlag = 0 <\/p>\n<p>set nocount on     <br \/>select &#8216;Hello &#8216; + @name&#160; +&#8217;,&#8217;     <br \/>union all      <br \/>select case when @celebrateChristmasFlag = 1 then      <br \/>&#160;&#160;&#160;&#160;&#160;&#160; CAST(0x4D65727279204368726973746D61732C204861707079204E6577205965617221 as varchar(40))      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; else CAST(0x536561736F6E73204772656574696E677321 as varchar(30)) end      <br \/>union all      <br \/>select &#8221;      <br \/>union all      <br \/>select CAST(0x492077616E7420746F207769736820796F7520616E6420796F7572732061207665727920686170707920686F6C6964617920736561736F6E as varchar(60))      <br \/>union all      <br \/>select CAST(0x66726F6D20616C6C206F6620757320617420647273716C2E6F7267202877656C6C206974206973206A757374206D652C207265616C6C7929 as varchar(60))      <br \/>union all      <br \/>select &#8221;      <br \/>union all       <br \/>select CAST(0x5468616E6B20796F7520666F722072656164696E67206D7920626C6F672C20616E64204920686F706520796F752077696C6C20636F6E74696E7565 as varchar(60))      <br \/>union all      <br \/>select CAST(0x746F207265616420696E20746865206E657720796561722C20616E6420796561727320746F20636F6D652E204920686F70652074686174 as varchar(60))      <br \/>union all      <br \/>select CAST(0x796F7520676574207468617420 as varchar(20)) + @presentYouWant      <br \/>union all      <br \/>select case when @believeInSantaFlag = 1       <br \/>&#160;&#160;&#160;&#160;&#160;&#160; then CAST(0x66726F6D2074686520626967206A6F6C6C7920677579206E616D65642053616E746120436C61757321 as varchar(60))      <br \/>&#160;&#160;&#160;&#160;&#160;&#160; else cast(0x66726F6D20736F6D656F6E6520796F7520646F6E27742073686172652061206372656469742063617264207769746821 as varchar(60)) end      <br \/>union all      <br \/>select &#8221;      <br \/>union all      <br \/>select cast(0x53656520796F7520696E2074686520636F6D696E6720796561722120204C6F756973 as varchar(60))<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My family used to send out Christmas cards with a yearly report of &quot;where we are from whenst we came from&quot; report, but some years we depressed people, but too often it sounded like bragging. This year I could neither brag nor depress, for it has been a pretty even Steven kind of year. Some&#8230;&hellip;<\/p>\n","protected":false},"author":56085,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[],"coauthors":[19684],"class_list":["post-82071","post","type-post","status-publish","format-standard","hentry","category-blogs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/82071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/56085"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=82071"}],"version-history":[{"count":1,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/82071\/revisions"}],"predecessor-version":[{"id":82289,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/82071\/revisions\/82289"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=82071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=82071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=82071"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=82071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}