SQL Clone
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
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15144 Visits: 18599
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
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1584 Visits: 3317
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
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

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

:-DBrilliant!
Cool
mickyT
mickyT
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1584 Visits: 3317
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
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4124 Visits: 7865
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
    SSCommitted
    SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

    Group: General Forum Members
    Points: 1584 Visits: 3317
    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
    One Orange Chip
    One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

    Group: General Forum Members
    Points: 27389 Visits: 13268
    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?
    My blog at SQLKover.

    MCSE Business Intelligence - Microsoft Data Platform MVP
    Eirikur Eiriksson
    Eirikur Eiriksson
    SSCoach
    SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

    Group: General Forum Members
    Points: 15144 Visits: 18599
    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
    SSCarpal Tunnel
    SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

    Group: General Forum Members
    Points: 4124 Visits: 7865
    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
    SSCertifiable
    SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)

    Group: General Forum Members
    Points: 5466 Visits: 35417
    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