Ask Question?


3 comments:

  1. How do we insert the results of the stored procedure in a table?

    ReplyDelete
  2. can we generate An Armstrong number using SQL script?

    ReplyDelete
    Replies
    1. If the sum of the cubes of individual digits of a number is equal to that number, it is an Armstrong number.
      WITH ArmStrong AS(
      SELECT
      0 AS Num
      UNION ALL
      SELECT
      Num+1
      FROM ArmStrong
      WHERE Num < 999
      )
      SELECT
      ArmstrongNumber = Num
      FROM ArmStrong
      WHERE
      Num = POWER(COALESCE(SUBSTRING(cast(Num AS VARCHAR(10)),1,1),0),3)
      + POWER(COALESCE(SUBSTRING(cast(Num AS VARCHAR(10)),2,1),0),3)
      + POWER(COALESCE(SUBSTRING(cast(Num AS VARCHAR(10)),3,1),0),3)
      OPTION(MAXRECURSION 0)

      Delete