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. Cursor and set , execute Statement related Query

Cursor and set , execute Statement related Query

Scheduled Pinned Locked Moved Database
sharepointdatabasetutorial
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.
  • P Offline
    P Offline
    param thaker
    wrote on last edited by
    #1

    Hi friends I want to execute the procedure which is as shown below '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' CREATE procedure xyz(@refno as varchar(25),@Type as varchar(15)) as set nocount on Create Table #tbl_xyz ( 'some fileds ) Set @Tempcode=0 Declare xyz_cursor Cursor for Set @sql1 = 'Select a,b c and d like ''' + @labrefno + ''' order by e ' + @Type exec sp_executesql @sql1 Open xyz_cursor Fetch next from xyz_cursor into some values While @@Fetch_status=0 BEGIN ''''''''' BEGIN END '''''''''''''' '''''''''''''' '''''''''''''' Close xyz_cursor Deallocate xyz_cursor select * from #tbl_xyz ''''''''''''''''''''''''''''''''''''''''''''' In the execution of above procedure , it won't allow me to set any value under the cursor declaration and even if execute under the cusor and i want to perform this procedure by passing the '@refno' and '@Type' dynamically as a parameter . Is there any solution regarding this , then please guide me. Thanks Param

    param

    F 1 Reply Last reply
    0
    • P param thaker

      Hi friends I want to execute the procedure which is as shown below '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' CREATE procedure xyz(@refno as varchar(25),@Type as varchar(15)) as set nocount on Create Table #tbl_xyz ( 'some fileds ) Set @Tempcode=0 Declare xyz_cursor Cursor for Set @sql1 = 'Select a,b c and d like ''' + @labrefno + ''' order by e ' + @Type exec sp_executesql @sql1 Open xyz_cursor Fetch next from xyz_cursor into some values While @@Fetch_status=0 BEGIN ''''''''' BEGIN END '''''''''''''' '''''''''''''' '''''''''''''' Close xyz_cursor Deallocate xyz_cursor select * from #tbl_xyz ''''''''''''''''''''''''''''''''''''''''''''' In the execution of above procedure , it won't allow me to set any value under the cursor declaration and even if execute under the cusor and i want to perform this procedure by passing the '@refno' and '@Type' dynamically as a parameter . Is there any solution regarding this , then please guide me. Thanks Param

      param

      F Offline
      F Offline
      Frank Kerrigan
      wrote on last edited by
      #2

      Do you have to use cursors 99% of the time you don't. What are you trying to do ?


      Blog Have I http:\\www.frankkerrigan.com

      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