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. SQL:Problem in dynamic sql query [modified]

SQL:Problem in dynamic sql query [modified]

Scheduled Pinned Locked Moved Database
databasehelptutorial
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.
  • X Offline
    X Offline
    xodeblack
    wrote on last edited by
    #1

    static query executes fine but there is problem when I make it dynamic.please ignore logic of query,only consider syntax

    	set @sSQL = 'select s.first\_name from sfm\_students s
                   left outer join 
                   (select seq\_id from sfm\_classes)c 
                   on c.seq\_id = s.sfm\_classes\_seq\_id'
    print @sSQL
        exec @sSQL
    

    when executing above procedure For Example

    exec GetInfo

    following error produce

    Msg 203, Level 16, State 2, Procedure GetInfo, Line 15
    The name 'select s.first_name from sfm_students s
    left outer join
    (select seq_id from sfm_classes)c
    on c.seq_id = s.sfm_classes_seq_id' is not a valid identifier.

    modified on Friday, August 28, 2009 5:15 AM

    M 1 Reply Last reply
    0
    • X xodeblack

      static query executes fine but there is problem when I make it dynamic.please ignore logic of query,only consider syntax

      	set @sSQL = 'select s.first\_name from sfm\_students s
                     left outer join 
                     (select seq\_id from sfm\_classes)c 
                     on c.seq\_id = s.sfm\_classes\_seq\_id'
      print @sSQL
          exec @sSQL
      

      when executing above procedure For Example

      exec GetInfo

      following error produce

      Msg 203, Level 16, State 2, Procedure GetInfo, Line 15
      The name 'select s.first_name from sfm_students s
      left outer join
      (select seq_id from sfm_classes)c
      on c.seq_id = s.sfm_classes_seq_id' is not a valid identifier.

      modified on Friday, August 28, 2009 5:15 AM

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

      try exec (getinfo)

      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