Results 1 to 3 of 3

Thread: Dynamically building SQL Statment in SQL Server Stored Procs

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Location
    Reading
    Posts
    70

    Dynamically building SQL Statment in SQL Server Stored Procs

    I'm quite new to writing SQL server stored procs.

    Normally in an asp page I would write build my SQL statement dyanamically, adding column names and value names depending on values that had been passed to the page.

    In SQL server I can dynamically add the value using a parameter, but it would seem to be the case the column names have to be hard coded. Is this true, or is there a way that I can dynamically build the column list on the basis of the parameters passed to the procedure?

    Cheers.


  2. #2
    Fanatic Member Bonker Gudd's Avatar
    Join Date
    Mar 2000
    Location
    Saturn
    Posts
    748
    In an SP, you can build your SQL in a string and then do EXEC(@string)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Location
    Reading
    Posts
    70
    Bonker Gudd you are a gent and a scholar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width