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. Output

Output

Scheduled Pinned Locked Moved Database
question
3 Posts 3 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

    If I have the following code Exec('Select Count(*) From table') how can I put the value of the execution into an integer type variable

    S K 2 Replies Last reply
    0
    • J jonhbt

      If I have the following code Exec('Select Count(*) From table') how can I put the value of the execution into an integer type variable

      S Offline
      S Offline
      scottgp
      wrote on last edited by
      #2

      I honestly didn't know either, but a quick search found http://www.sqlteam.com/article/return-recordsets-from-dynamic-queries-called-by-exec[^] and http://www.sommarskog.se/dynamic_sql.html[^]. The second article looks very complete, and it looks like you might want to check out sp_executesql. Scott

      1 Reply Last reply
      0
      • J jonhbt

        If I have the following code Exec('Select Count(*) From table') how can I put the value of the execution into an integer type variable

        K Offline
        K Offline
        Kevin Horgan
        wrote on last edited by
        #3

        Hi, If you just what to store the COUNT value in a variable (@a) you could do this. declare @a int select @a = (SELECT COUNT(*) FROM table) Now select the count value from the variable... select @a

        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