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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Nested Stored Procedure

Nested Stored Procedure

Scheduled Pinned Locked Moved Database
databasequestion
5 Posts 4 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.
  • J Offline
    J Offline
    jonhbt
    wrote on last edited by
    #1

    hi, i need to create a stored procedure with a Count(*) option and also an output parameter with the Id of the selected record. IS it possible?

    A M 2 Replies Last reply
    0
    • J jonhbt

      hi, i need to create a stored procedure with a Count(*) option and also an output parameter with the Id of the selected record. IS it possible?

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      Yes

      Bob Ashfield Consultants Ltd

      1 Reply Last reply
      0
      • J jonhbt

        hi, i need to create a stored procedure with a Count(*) option and also an output parameter with the Id of the selected record. IS it possible?

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Well the question does not make sense: ID infers a unique identifier Count(*) requires a group by So your question is can I group by a unique identifier. Try rephrasing the question (I think you just got it wrong) and give us some more detail.

        Never underestimate the power of human stupidity RAH

        V 1 Reply Last reply
        0
        • M Mycroft Holmes

          Well the question does not make sense: ID infers a unique identifier Count(*) requires a group by So your question is can I group by a unique identifier. Try rephrasing the question (I think you just got it wrong) and give us some more detail.

          Never underestimate the power of human stupidity RAH

          V Offline
          V Offline
          Venkat Eswaran
          wrote on last edited by
          #4

          Why do you use Count(*), it is better to use Count(ID) ID infers a unique identifier in that table CREATE PROCEDURE titles_count @@TITLE varchar(40) = '%', @@count int OUTPUT AS SELECT @@count = count(title_id) FROM titles WHERE title LIKE @@TITLE GO

          Venky

          M 1 Reply Last reply
          0
          • V Venkat Eswaran

            Why do you use Count(*), it is better to use Count(ID) ID infers a unique identifier in that table CREATE PROCEDURE titles_count @@TITLE varchar(40) = '%', @@count int OUTPUT AS SELECT @@count = count(title_id) FROM titles WHERE title LIKE @@TITLE GO

            Venky

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            Why is it better to use count(field) instead of count(*), I have never heard that there is a difference in cost

            Never underestimate the power of human stupidity RAH

            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