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. Sending Column Name From SP to C# App

Sending Column Name From SP to C# App

Scheduled Pinned Locked Moved Database
questioncsharpsharepointdatabase
6 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 Offline
    A Offline
    AmbiguousName
    wrote on last edited by
    #1

    hello guys... I have this stored proc which gets some values from table but in addition, it calculates some values like %age of result. The question is: how can I send this value WITH a column name like Percantage. Here is the query for stored proc but I dont know what to add

    CREATE PROCEDURE [dbo].[GetStudents] AS
    SELECT
    s.StudentId, s.FirstName,s.SurName,
    ( ((s.ObtMarks) / (s.TotalMarks)) * 100) --this is the value I want to send with column name

    FROM Students s

    GROUP BY
    s.StudentId, s.FirstName,s.SurName

    H K L 3 Replies Last reply
    0
    • A AmbiguousName

      hello guys... I have this stored proc which gets some values from table but in addition, it calculates some values like %age of result. The question is: how can I send this value WITH a column name like Percantage. Here is the query for stored proc but I dont know what to add

      CREATE PROCEDURE [dbo].[GetStudents] AS
      SELECT
      s.StudentId, s.FirstName,s.SurName,
      ( ((s.ObtMarks) / (s.TotalMarks)) * 100) --this is the value I want to send with column name

      FROM Students s

      GROUP BY
      s.StudentId, s.FirstName,s.SurName

      H Offline
      H Offline
      hypermellow
      wrote on last edited by
      #2

      Hi, try giving your calculate column value an alias. Then you can reference it by name in your c# datatable. I've modified (but no tested or ran) your procedure. Hope it helps,

      CREATE PROCEDURE [dbo].[GetStudents] AS
      SELECT
      s.StudentId, s.FirstName,s.SurName,
      ( ((s.ObtMarks) / (s.TotalMarks)) * 100) AS PercentageValue

      FROM Students s

      GROUP BY
      s.StudentId, s.FirstName,s.SurName

      A 1 Reply Last reply
      0
      • H hypermellow

        Hi, try giving your calculate column value an alias. Then you can reference it by name in your c# datatable. I've modified (but no tested or ran) your procedure. Hope it helps,

        CREATE PROCEDURE [dbo].[GetStudents] AS
        SELECT
        s.StudentId, s.FirstName,s.SurName,
        ( ((s.ObtMarks) / (s.TotalMarks)) * 100) AS PercentageValue

        FROM Students s

        GROUP BY
        s.StudentId, s.FirstName,s.SurName

        A Offline
        A Offline
        AmbiguousName
        wrote on last edited by
        #3

        just put colName = Calculated Value and you are good to go :)

        1 Reply Last reply
        0
        • A AmbiguousName

          hello guys... I have this stored proc which gets some values from table but in addition, it calculates some values like %age of result. The question is: how can I send this value WITH a column name like Percantage. Here is the query for stored proc but I dont know what to add

          CREATE PROCEDURE [dbo].[GetStudents] AS
          SELECT
          s.StudentId, s.FirstName,s.SurName,
          ( ((s.ObtMarks) / (s.TotalMarks)) * 100) --this is the value I want to send with column name

          FROM Students s

          GROUP BY
          s.StudentId, s.FirstName,s.SurName

          K Offline
          K Offline
          Karthik Harve
          wrote on last edited by
          #4

          just change the query like this..

          SELECT
          s.StudentId, s.FirstName,s.SurName,
          ( 'Percentage - ' + ((s.ObtMarks) / (s.TotalMarks)) * 100) as 'Percentage'

          hope it works..

          with regards Karthik Harve

          1 Reply Last reply
          0
          • A AmbiguousName

            hello guys... I have this stored proc which gets some values from table but in addition, it calculates some values like %age of result. The question is: how can I send this value WITH a column name like Percantage. Here is the query for stored proc but I dont know what to add

            CREATE PROCEDURE [dbo].[GetStudents] AS
            SELECT
            s.StudentId, s.FirstName,s.SurName,
            ( ((s.ObtMarks) / (s.TotalMarks)) * 100) --this is the value I want to send with column name

            FROM Students s

            GROUP BY
            s.StudentId, s.FirstName,s.SurName

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

            can be a useful keyword. :)

            Luc Pattyn [My Articles] Nil Volentibus Arduum

            S 1 Reply Last reply
            0
            • L Luc Pattyn

              can be a useful keyword. :)

              Luc Pattyn [My Articles] Nil Volentibus Arduum

              S Offline
              S Offline
              SilimSayo
              wrote on last edited by
              #6

              Provided you don't misspell it by adding an extra 's' :)

              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