Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Sql server

Sql server

Scheduled Pinned Locked Moved Database
databasesql-serversysadmin
15 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A anup keshari

    1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9

    B Offline
    B Offline
    Blue_Boy
    wrote on last edited by
    #4

    Here it is: DECLARE @i AS INT SET @i=0 DECLARE @j AS INT SET @j=1 DECLARE @kosova AS VARCHAR(255) SET @kosova='' WHILE(@i<10) BEGIN WHILE(@j<@i) BEGIN SET @kosova=@kosova+CAST(@i AS VARCHAR(10)) SET @j=@j+1 END PRINT @kosova set @kosova='' SET @j=0 SET @i=@i+1 END


    I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

    A 1 Reply Last reply
    0
    • B Blue_Boy

      Here it is: DECLARE @i AS INT SET @i=0 DECLARE @j AS INT SET @j=1 DECLARE @kosova AS VARCHAR(255) SET @kosova='' WHILE(@i<10) BEGIN WHILE(@j<@i) BEGIN SET @kosova=@kosova+CAST(@i AS VARCHAR(10)) SET @j=@j+1 END PRINT @kosova set @kosova='' SET @j=0 SET @i=@i+1 END


      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

      A Offline
      A Offline
      anup keshari
      wrote on last edited by
      #5

      1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9

      B 1 Reply Last reply
      0
      • A anup keshari

        1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9

        B Offline
        B Offline
        Blue_Boy
        wrote on last edited by
        #6

        And your question is? I don't understand what you mean by this last pyramid!


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

        A 1 Reply Last reply
        0
        • B Blue_Boy

          And your question is? I don't understand what you mean by this last pyramid!


          I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

          A Offline
          A Offline
          anup keshari
          wrote on last edited by
          #7

          1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 here the 1 printed after 8 spaces 1 times here 2 printed after 7 spaces 2 times . and so on .

          L 1 Reply Last reply
          0
          • A anup keshari

            how i can create pyramid in sql server 2005.

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #8

            That is similar to calculating Mandelbrot sets in SQL, only somewhat faster. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


            modified on Saturday, March 28, 2009 1:46 PM

            E 1 Reply Last reply
            0
            • A anup keshari

              1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 here the 1 printed after 8 spaces 1 times here 2 printed after 7 spaces 2 times . and so on .

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #9

              You're cheating! You can't get a decent pyramid by adding a number, you'll have to add two numbers to get a decent pyramid :laugh:

              1
              222
              33333
              4444444

              I are troll :)

              A 1 Reply Last reply
              0
              • L Lost User

                You're cheating! You can't get a decent pyramid by adding a number, you'll have to add two numbers to get a decent pyramid :laugh:

                1
                222
                33333
                4444444

                I are troll :)

                A Offline
                A Offline
                anup keshari
                wrote on last edited by
                #10

                i think u should try it , its possible in sqlserver . so dont laugh ,but try it.

                L 2 Replies Last reply
                0
                • A anup keshari

                  i think u should try it , its possible in sqlserver . so dont laugh ,but try it.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #11

                  I enjoy making and solving these kind of riddles, it's a fun way of learning :) I'm still @work, but I'll give it a try to build my pyramid when I'm home :thumbsup:

                  I are troll :)

                  1 Reply Last reply
                  0
                  • A anup keshari

                    i think u should try it , its possible in sqlserver . so dont laugh ,but try it.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #12

                    Result

                          0
                         111
                        22222
                       3333333
                      444444444
                     55555555555
                    6666666666666
                    

                    777777777777777
                    88888888888888888
                    9999999999999999999

                    Here's my homework;

                    DECLARE @R AS INT
                    SET @R = 0
                    DECLARE @FILL AS INT
                    SET @FILL = 10
                    DECLARE @NUMCNT AS INT
                    SET @NUMCNT = 1

                    DECLARE @ROWSTR AS VARCHAR(100)
                    DECLARE @I AS INT

                    WHILE (@R < 10)
                    BEGIN
                    SET @ROWSTR = ''

                      SET @I = 0
                      WHILE (@I < @FILL)
                      BEGIN
                            SET @ROWSTR = @ROWSTR + ' '
                            SET @I = @I + 1
                      END
                    
                      SET @I = 0
                      WHILE (@I < @NUMCNT)
                      BEGIN
                            SET @ROWSTR = @ROWSTR + CAST(@R AS VARCHAR)
                            SET @I = @I + 1            
                      END
                    
                      SET @R = @R + 1
                      SET @FILL = @FILL - 1
                      SET @NUMCNT = @NUMCNT + 2
                    
                    PRINT @ROWSTR
                    

                    END

                    :suss:

                    I are troll :)

                    A 1 Reply Last reply
                    0
                    • L Lost User

                      Result

                            0
                           111
                          22222
                         3333333
                        444444444
                       55555555555
                      6666666666666
                      

                      777777777777777
                      88888888888888888
                      9999999999999999999

                      Here's my homework;

                      DECLARE @R AS INT
                      SET @R = 0
                      DECLARE @FILL AS INT
                      SET @FILL = 10
                      DECLARE @NUMCNT AS INT
                      SET @NUMCNT = 1

                      DECLARE @ROWSTR AS VARCHAR(100)
                      DECLARE @I AS INT

                      WHILE (@R < 10)
                      BEGIN
                      SET @ROWSTR = ''

                        SET @I = 0
                        WHILE (@I < @FILL)
                        BEGIN
                              SET @ROWSTR = @ROWSTR + ' '
                              SET @I = @I + 1
                        END
                      
                        SET @I = 0
                        WHILE (@I < @NUMCNT)
                        BEGIN
                              SET @ROWSTR = @ROWSTR + CAST(@R AS VARCHAR)
                              SET @I = @I + 1            
                        END
                      
                        SET @R = @R + 1
                        SET @FILL = @FILL - 1
                        SET @NUMCNT = @NUMCNT + 2
                      
                      PRINT @ROWSTR
                      

                      END

                      :suss:

                      I are troll :)

                      A Offline
                      A Offline
                      anup keshari
                      wrote on last edited by
                      #13

                      ITS GOOD BUT THE RESULT IS NOT SO DESIREABLE . BECAE WHEN I PASS 5 THEN ITS NOT GINGING THE PROPER RESULT I NEED A DYNAMIC FUNCTION FOR ANY INPUT VALUE EX .FOR 5 1 ,1 TIMES 2 2 ,2 TIMES 3 3 3 ,3 TIMES 4 4 4 4 ,4 TIMES 5 5 5 5 5 ,5 TIMES I NEDD LIKE ABOVE

                      L 1 Reply Last reply
                      0
                      • A anup keshari

                        ITS GOOD BUT THE RESULT IS NOT SO DESIREABLE . BECAE WHEN I PASS 5 THEN ITS NOT GINGING THE PROPER RESULT I NEED A DYNAMIC FUNCTION FOR ANY INPUT VALUE EX .FOR 5 1 ,1 TIMES 2 2 ,2 TIMES 3 3 3 ,3 TIMES 4 4 4 4 ,4 TIMES 5 5 5 5 5 ,5 TIMES I NEDD LIKE ABOVE

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #14

                        Well, it's *your* homework obvious, not mine ;P Besides, my pyramid differs from yours, so you'll have to write your own anyway.. See, this below was your desired pyramidresult:

                            1
                           2 2
                          3 3 3
                         4 4 4 4
                        5 5 5 5 5
                        

                        6 6 6 6 6 6
                        7 7 7 7 7 7 7
                        8 8 8 8 8 8 8 8
                        9 9 9 9 9 9 9 9 9

                        and this was mine:

                              0
                             111
                            22222
                           3333333
                          444444444
                         55555555555
                        6666666666666
                        

                        777777777777777
                        88888888888888888
                        9999999999999999999

                        Your pyramid should only grow by a single number (e.g. 22 -> 333), whilst mine adds two numbers to each row (e.g. 111 -> 222 + 22 = 22222) Good luck :thumbsup:

                        I are troll :)

                        1 Reply Last reply
                        0
                        • L Luc Pattyn

                          That is similar to calculating Mandelbrot sets in SQL, only somewhat faster. :)

                          Luc Pattyn [Forum Guidelines] [My Articles]


                          - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


                          modified on Saturday, March 28, 2009 1:46 PM

                          E Offline
                          E Offline
                          Eytukan
                          wrote on last edited by
                          #15

                          how i can create pyramid in sql server 2005. Do you having something called SQL-Pyramid-Building-Blocks? just like we have Intel Thread Building Blocks? :rolleyes: if one exists,I wish to suggest that to the OP!

                          He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups