Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


The fun factor: Magical numbers and other peculiarities


The fun factor: Magical numbers and other peculiarities

Author
Message
Eirikur Eiriksson
Eirikur Eiriksson
SSCertifiable
SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)

Group: General Forum Members
Points: 6743 Visits: 17721
Looking for something that brings a smile:-D, here's the first contribution
Cool

DECLARE @QUESTION VARCHAR(50) = 'Last time England won the World Cup?';
SELECT CONVERT(BIGINT,CONVERT(VARBINARY(50),@QUESTION,0),1) ^ 0x726C642043757791


mickyT
mickyT
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1253 Visits: 3309
To stick with a theme :-)
DECLARE @Team1 VARCHAR(10) = 'Italy'
DECLARE @Team2 VARCHAR(10) = 'England'

SELECT @Team1 + ': ' + CAST(LEN(@Team1) % 3 AS VARCHAR(2)),
@Team2 + ': ' + CAST(LEN(@Team2) % 3 AS VARCHAR(2))


Eirikur Eiriksson
Eirikur Eiriksson
SSCertifiable
SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)

Group: General Forum Members
Points: 6743 Visits: 17721
mickyT (6/15/2014)
To stick with a theme :-)

:-DBrilliant!
Cool
mickyT
mickyT
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1253 Visits: 3309
Without wanting to pick on any nation in particular;-)
SELECT TeamName + ': '+ CAST(Score AS VARCHAR(2))
FROM (VALUES ('England'), ('All Blacks')) team (TeamName)
CROSS APPLY (
SELECT 4 * LEN(REPLACE(REPLACE(TeamName,SUBSTRING(TeamName,1,1),''),' ','')) +
(LEN(TeamName) % 4) * (LEN(TeamName) % 2)
) result(Score)
ORDER BY TeamName


mister.magoo
mister.magoo
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2272 Visits: 7827
It's not very fancy, but I have found a query where NOLOCK really is desirable...

SELECT result FROM fifaworldcup2014 WITH(NOLOCK) WHERE team='ENGLAND'

Here's hoping for that "incorrect data" we are constantly warned about :-P

MM


select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);




  • Forum Etiquette: How to post Reporting Services problems
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • How to Post Performance Problems - by Gail Shaw

  • mickyT
    mickyT
    Ten Centuries
    Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

    Group: General Forum Members
    Points: 1253 Visits: 3309
    Promise this will be my last oneWhistling

    DECLARE @Question VARCHAR(50) = 'Year that England last beat Italy?'

    SELECT CAST(
    POWER(LEN(Italy),ItalyLastScore) *
    POWER(LEN(England),EnglandLastScore) *
    (LEN(@Question) / (ItalyLastScore + EnglandLastScore))
    - (ItalyTotalWins - EnglandTotalWins)
    - (TotalDraws / 2)
    AS INT
    )
    FROM (VALUES ('Italy',2.0,'England',1.0,11.0,8.0,6.0))
    Stats(Italy, ItalyLastScore,
    England, EnglandLastScore,
    ItalyTotalWins, EnglandTotalWins, TotalDraws)


    Koen Verbeeck
    Koen Verbeeck
    SSCoach
    SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

    Group: General Forum Members
    Points: 16455 Visits: 13207
    SELECT 'Last Time Belgium Won the World Cup' = 1/0;



    Sad



    How to post forum questions.
    Need an answer? No, you need a question.
    What’s the deal with Excel & SSIS?

    Member of LinkedIn. My blog at SQLKover.

    MCSA SQL Server 2012 - MCSE Business Intelligence
    Eirikur Eiriksson
    Eirikur Eiriksson
    SSCertifiable
    SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)

    Group: General Forum Members
    Points: 6743 Visits: 17721
    mister.magoo (6/15/2014)
    It's not very fancy, but I have found a query where NOLOCK really is desirable...

    SELECT result FROM fifaworldcup2014 WITH(NOLOCK) WHERE team='ENGLAND'

    Here's hoping for that "incorrect data" we are constantly warned about :-P


    Tried the code but something is wrong, constantly got the same error message
    Cool
    'Transaction (Process ID 2014) was lost on resources with another process 
    and has been chosen as the tournament victim. Rerun tournament.'


    mister.magoo
    mister.magoo
    SSCrazy
    SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

    Group: General Forum Members
    Points: 2272 Visits: 7827
    Eirikur Eiriksson (6/16/2014)
    mister.magoo (6/15/2014)
    It's not very fancy, but I have found a query where NOLOCK really is desirable...

    SELECT result FROM fifaworldcup2014 WITH(NOLOCK) WHERE team='ENGLAND'

    Here's hoping for that "incorrect data" we are constantly warned about :-P


    Tried the code but something is wrong, constantly got the same error message
    Cool
    'Transaction (Process ID 2014) was lost on resources with another process 
    and has been chosen as the tournament victim. Rerun tournament.'



    Use trace flag 1966

    MM


    select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);




  • Forum Etiquette: How to post Reporting Services problems
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • How to Post Performance Problems - by Gail Shaw

  • J Livingston SQL
    J Livingston SQL
    Hall of Fame
    Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

    Group: General Forum Members
    Points: 3448 Visits: 33040
    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 ON
    IF object_id('tempdb..#ParallelUniverse') IS NOT NULL
    DROP TABLE #ParallelUniverse

    SELECT top (len(@Source)) IDENTITY(INT, 1, 1) n
    INTO #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.. ' + @Answer
    SET 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
    */




    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

    Go


    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

































































































































































    SQLServerCentral


    Search