Log in  ::  Register  ::  Not logged in

The fun factor: Magical numbers and other peculiarities

 Author Message Koen Verbeeck SSC Guru Group: General Forum Members Points: 145334 Visits: 13350 J Livingston SQL (6/16/2014)my effort...too much time on my hands :-D...Nice :-D How to post forum questions.Need an answer? No, you need a question.What’s the deal with Excel & SSIS?My blog at SQLKover.MCSE Business Intelligence - Microsoft Data Platform MVP graham.smith Valued Member Group: General Forum Members Points: 61 Visits: 238 You all have too much time on your hands, Eirik, get back to work....... :-DGraham Eirikur Eiriksson SSC Guru Group: General Forum Members Points: 93633 Visits: 20656 graham.smith (6/16/2014)You all have too much time on your hands, Eirik, get back to work....... :-DGrahamDon't worry my friend, this is a key to enjoying work! I have been laughing all the way to work and back, thank you guys! You would all do good in the Office of National Statistics:-PPlease don't stop, I'll contribute when I can;-) mickyT SSCertifiable Group: General Forum Members Points: 5770 Visits: 3320 J Livingston SQL (6/16/2014)my effort...too much time on my hands :-D`DECLARE @Question VARCHAR(100) = 'The Answer to the Ultimate Question of Life, the Universe, and Everything'DECLARE @Source VARCHAR(100) ='The Hitchhikers Guide to the Galaxy'DECLARE @Answer VARCHAR(10)SET NOCOUNT ONIF object_id('tempdb..#ParallelUniverse') IS NOT NULLDROP TABLE #ParallelUniverseSELECT top (len(@Source)) IDENTITY(INT, 1, 1) nINTO #ParallelUniverse FROM master.sys.all_columns SET @Answer = (select len(@Question) - (SELECT MAX(n) from ((SELECT n FROM #ParallelUniverse )EXCEPT(SELECT (PU1.n * PU2.n) AS cn FROM #ParallelUniverse AS PU1, #ParallelUniverse AS PU2 WHERE PU1.n BETWEEN 2 AND CEILING (SQRT (1000)) AND PU2.n BETWEEN 2 AND CEILING (SQRT (1000)) AND PU1.n <= PU2.n AND (PU1.n * PU2.n) <= 1000) )x)) PRINT @Question + ' is.. ' + @AnswerSET NOCOUNT OFF/*code to find primes courtesy of J Celko in this discussion:http://social.msdn.microsoft.com/Forums/sqlserver/en-US/90a58cc7-dada-476a-8d27-f744c71940e6/how-to-find-whether-is-a-prime-or-non-prime-with-one-select-statement?forum=transactsql*/`Awesome:-) mickyT SSCertifiable Group: General Forum Members Points: 5770 Visits: 3320 One to make you smile if you have 2012:-)`DECLARE @smiley varchar(20) = 'Dont Worry Be Happy';WITH Params AS ( SELECT MAX(CASE WHEN ItemNumber = 1 THEN Val END) OFFSET, MAX(CASE WHEN ItemNumber = 2 THEN Val END) BASE, MAX(CASE WHEN ItemNumber = 3 THEN Val END) BASEMULTIPLIER, MAX(CASE WHEN ItemNumber = 4 THEN Val END) BASEDIVISOR FROM ( SELECT ItemNumber, Item, LEN(Item) Val FROM [dbo].[DelimitedSplit8K](@smiley,' ') ) s )SELECT @smiley Quote, Geometry:oint(BASE * BASEMULTIPLIER, BASE * BASEMULTIPLIER,0).STBuffer(BASE * BASEMULTIPLIER).STDifference(( SELECT Geometry::UnionAggregate(g) FROM ( SELECT Geometry:oint(BASE * BASEMULTIPLIER - OFFSET, BASE * BASEMULTIPLIER + OFFSET,0).STBuffer(BASE / BASEDIVISOR) g FROM Params UNION ALL SELECT Geometry:oint(BASE * BASEMULTIPLIER + OFFSET, BASE * BASEMULTIPLIER + OFFSET,0).STBuffer(BASE / BASEDIVISOR) g FROM Params UNION ALL SELECT Geometry::STGeomFromText( CONCAT('CIRCULARSTRING(', BASE * BASEMULTIPLIER - OFFSET, ' ', BASE * BASEMULTIPLIER - OFFSET, ', ', BASE * BASEMULTIPLIER , ' ', (BASE * BASEMULTIPLIER - OFFSET) - ((BASE * BASEMULTIPLIER) / (BASE * BASEMULTIPLIER - OFFSET)), ', ', BASE * BASEMULTIPLIER + OFFSET, ' ', BASE * BASEMULTIPLIER - OFFSET, ')'),0).STBuffer(BASE / BASEDIVISOR) g FROM Params ) a )) Smiley FROM Params;--Now switch to Spatial Results Tab `Edit: Tweaked Slightly Koen Verbeeck SSC Guru Group: General Forum Members Points: 145334 Visits: 13350 mickyT (6/16/2014)One to make you smile if you have 2012:-)...Msg 208, Level 16, State 1, Line 3Invalid object name 'dbo.DelimitedSplit8K'. How to post forum questions.Need an answer? No, you need a question.What’s the deal with Excel & SSIS?My blog at SQLKover.MCSE Business Intelligence - Microsoft Data Platform MVP mickyT SSCertifiable Group: General Forum Members Points: 5770 Visits: 3320 Koen Verbeeck (6/17/2014)mickyT (6/16/2014)One to make you smile if you have 2012:-)...Msg 208, Level 16, State 1, Line 3Invalid object name 'dbo.DelimitedSplit8K'.Sorry, this function is from this article by Jeff Moden. Koen Verbeeck SSC Guru Group: General Forum Members Points: 145334 Visits: 13350 mickyT (6/17/2014)Koen Verbeeck (6/17/2014)mickyT (6/16/2014)One to make you smile if you have 2012:-)...Msg 208, Level 16, State 1, Line 3Invalid object name 'dbo.DelimitedSplit8K'.Sorry, this function is from this article by Jeff Moden.I know, and it should be standard on every database :-D(but apparently not on my test database) How to post forum questions.Need an answer? No, you need a question.What’s the deal with Excel & SSIS?My blog at SQLKover.MCSE Business Intelligence - Microsoft Data Platform MVP Eirikur Eiriksson SSC Guru Group: General Forum Members Points: 93633 Visits: 20656 If Einstein would have had SQL Server, it would have been so much easier:-D`USE tempdb;GO;WITH SQL_VISDOM AS( SELECT ROW_NUMBER() OVER (ORDER BY (SAO.object_id ^ -1)) AS SCHOOL_YEARS ,SAO.object_id + ROW_NUMBER() OVER (ORDER BY (SAO.object_id ^ -1)) AS SCHOOL_ATTEMPTS ,SAO.object_id ^ -1 SCHOOL_FAILURES FROM sys.all_objects SAO WHERE SAO.object_id < 0),DOING_LEARNING AS( SELECT SV.SCHOOL_YEARS ,SV.SCHOOL_ATTEMPTS ,SV.SCHOOL_FAILURES ,DENSE_RANK() OVER (ORDER BY (SV.SCHOOL_ATTEMPTS ^ -1)) AS TEST_RATING ,RANK() OVER (ORDER BY (SV.SCHOOL_ATTEMPTS ^ -1)) AS TEST_GROUP ,SV.SCHOOL_YEARS * DENSE_RANK() OVER (ORDER BY (SV.SCHOOL_ATTEMPTS ^ -1)) + (SV.SCHOOL_ATTEMPTS % 100) AS YEARS_LEFT FROM SQL_VISDOM SV)SELECT CHAR( DL.TEST_GROUP * DL.TEST_RATING) + CHAR((DL.TEST_GROUP * DL.TEST_RATING) + POWER(DL.SCHOOL_FAILURES + DL.SCHOOL_ATTEMPTS - (DL.SCHOOL_YEARS - DL.TEST_RATING),DL.TEST_RATING) * SIGN(DL.SCHOOL_ATTEMPTS)) + CHAR((DL.TEST_GROUP * DL.TEST_RATING) + POWER(DL.SCHOOL_FAILURES + DL.SCHOOL_ATTEMPTS - (DL.SCHOOL_YEARS - DL.TEST_RATING),DL.TEST_RATING) * SIGN(ABS(DL.SCHOOL_ATTEMPTS))) + CHAR(ABS((DL.SCHOOL_ATTEMPTS + DL.SCHOOL_YEARS) + CEILING(TEST_GROUP / 2)) / 2) + CHAR((DL.TEST_GROUP * 2 + POWER(DL.SCHOOL_ATTEMPTS,DL.YEARS_LEFT)) * 2) + CHAR(((DL.TEST_GROUP * (CEILING(DL.TEST_RATING / 2)) * 2) + FLOOR(SQRT(DL.SCHOOL_YEARS))))FROM DOING_LEARNING DLWHERE DL.YEARS_LEFT = 0;` graham.smith Valued Member Group: General Forum Members Points: 61 Visits: 238 Brilliant Erik, love it. :-D

Permissions

 You can't post new topics. You can't post topic replies. You can't post new polls. You can't post replies to polls. You can't edit your own topics. You can't delete your own topics. You can't edit other topics. You can't delete other topics. You can't edit your own posts. You can't edit other posts. You can't delete your own posts. You can't delete other posts. You can't post events. You can't edit your own events. You can't edit other events. You can't delete your own events. You can't delete other events. You can't send private messages. You can't send emails. You can read topics. You can't vote in polls. You can't upload attachments. You can download attachments. You can't post HTML code. You can't edit HTML code. You can't post IFCode. You can't post JavaScript. You can post emoticons. You can't post or upload images.

Select a forum
 SQL Server 2017      SQL Server 2017 - Administration      SQL Server 2017 - Development SQL Server 2016      SQL Server 2016 - Administration      SQL Server 2016 - Development and T-SQL SQL Server 2014      Administration - SQL Server 2014      Development - SQL Server 2014 SQL Server 2012      SQL 2012 - General      SQL Server 2012 - T-SQL SQL Server vNext      SQL Server 15 - Administration      SQL Server 15 - Development SQL Server 2008      SQL Server 2008 - General      T-SQL (SS2K8)      June 2007 CTP      Working with Oracle      July CTP      SQL Server Newbies      Security (SS2K8)      SQL Server 2008 High Availability      SQL Server 2008 Administration      Data Corruption (SS2K8 / SS2K8 R2)      SQL Server 2008 Performance Tuning Cloud Computing      SQL Azure - Development      SQL Azure - Administration      Amazon AWS and other cloud vendors      General Cloud Computing Questions      CosmosDB      Azure Data Lake      Azure Machine Learning Reporting Services      Reporting Services      Reporting Services 2005 Administration      Reporting Services 2005 Development      Reporting Services 2008/R2 Administration      Reporting Services 2008 Development      SSRS 2012      SSRS 2014      SSRS 2016 Programming      Connecting      General      SMO/RMO/DMO      XML      Service Broker      Powershell      Testing      TFS/Data Dude/DBPro      SSDT      Continuous Integration, Deployment, and Delivery      R Services and R Language Data Warehousing      Integration Services      Strategies and Ideas      Analysis Services      Data Transformation Services (DTS)      Performance Point      Data Mining      PowerPivot      R language      Machine Learning Database Design      Disaster Recovery      Design Ideas and Questions      Relational Theory      Hardware      Virtualization      Security and Auditing SQLServerCentral.com      Anything that is NOT about SQL!      Contests!      Editorials      SQLServerCentral.com Announcements      SQLServerCentral.com Website Issues      Suggestions      Tag Issues with Content      Podcast Feedback      SQLServerCentral.com Test Forum      Articles Requested SQL Server 2005      Administering      Backups      Business Intelligence      CLR Integration and Programming.      Data Corruption      Development      Working with Oracle      SQL Server 2005 Compact Edition      SQL Server 2005 General Discussion      SQL Server 2005 Security      SQL Server 2005 Strategies      SS2K5 Replication      SQL Server Express      SQL Server 2005 Performance Tuning      SQL Server 2005 Integration Services      T-SQL (SS2K5)      SQL Server Newbies SQL Server 7,2000      Administration      Backups      Data Corruption      General      Globalization      In The Enterprise      Working with Oracle      Security      Strategies      SQL Server Newbies      Service Packs      SQL Server CE      Performance Tuning      Replication      Sarbanes-Oxley      T-SQL      SQL Server Agent SQL Server and other platforms      MySQL      Oracle      PostgreSQL      DB2      SQL Server and Sharepoint Older Versions of SQL (v6.5, v6.0, v4.2)      Older Versions of SQL (v6.5, v6.0, v4.2) Career      Certification      Employers and Employees      Events      Job Postings      Resumes and Job Hunters      Presentations and Speaking      Retired Members Testing Center      SQL Server Security Skills      Question of the Day (QOD) Microsoft Access      Microsoft Access Products and Books      Third Party Products         SQLCentric         Extreme Technologies.         Innovartis         Embarcadero         SQL Sentry         Sonasoft         Golden Gate Software         Idera         Lumigent         Red Gate Software         ApexSQL         Quest Software         CA      Discussions about Books         Discuss Programming Books          Discuss XML Books          Discuss T-SQL Books          Discuss Data Warehousing Books          Discuss DTS Books          Discuss SQL Server 2000 Books         Discuss SQL Server 7.0 Books Notification Services      Administration Article Discussions Future Versions      SQL 12

Search

 Copyright © 2002-2018 Redgate. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.