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. need help

need help

Scheduled Pinned Locked Moved Database
databasehelp
2 Posts 2 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.
  • H Offline
    H Offline
    haseeb_saeed
    wrote on last edited by
    #1

    hello i wanted to make a single stored procedure which takes as parameter the table name from which all the rows should be selected ... in query analyzer i tried declare @var varchar(30); set @var='tableName'; select * from @var; but it won't work... the variable declaration and assignment works fine, but the select statement doesnt work... Please help in this regard... i also tried making declare @col_name varchar(30); set @col_name='studentName'; select @col_name from studentTable; it works but the rows returned have col_name as it's value and the original value doesn't appear Plz help

    haseeb

    A 1 Reply Last reply
    0
    • H haseeb_saeed

      hello i wanted to make a single stored procedure which takes as parameter the table name from which all the rows should be selected ... in query analyzer i tried declare @var varchar(30); set @var='tableName'; select * from @var; but it won't work... the variable declaration and assignment works fine, but the select statement doesnt work... Please help in this regard... i also tried making declare @col_name varchar(30); set @col_name='studentName'; select @col_name from studentTable; it works but the rows returned have col_name as it's value and the original value doesn't appear Plz help

      haseeb

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

      You have to use Dynamic EXECUTE or sp_executesql (recommended). Check Books Online sp_executesql topic. It has a good example.

      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