Re: Dynamically create stored procedure in sql server from a vb.net windows forms app

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Erland Sommarskog

    Re: Dynamically create stored procedure in sql server from a vb.net windows forms app

    Karl Rhodes (googlegroups@c ortexa.co.uk) writes:
    When I run this and check SQL Profiler I see the text "exec
    sp_executesql N'" before the word "CREATE" and get the error
    "incorrect syntax near the keyword 'PROCEDURE'"
    >
    Can anyone see where I'm going wrong, or does anyone know how to
    dynamically create a stored procedure in a sql server database in this
    way?
    The exact reason for the error is that you pass parameters to the
    command batch where you create the procedure. That does not fly. Nor
    would there be any point to so so.

    But I completely agree with Stephany Young's analysis. That stored
    procedure is completely meaningless, so it's a good thing that
    you are not able to create it.


    --
    Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

    Books Online for SQL Server 2005 at

    Books Online for SQL Server 2000 at

  • Karl Rhodes

    #2
    Re: Dynamically create stored procedure in sql server from a vb.netwindows forms app

    On 29 May, 23:00, Erland Sommarskog <esq...@sommars kog.sewrote:
    Karl Rhodes (googlegro...@c ortexa.co.uk) writes:
    When I run this and check SQL Profiler I see the text "exec
    sp_executesql N'" before the word "CREATE" and get the error
    "incorrect syntax near the keyword 'PROCEDURE'"
    >
    Can anyone see where I'm going wrong, or does anyone know how to
    dynamically create a stored procedure in a sql server database in this
    way?
    >
    The exact reason for the error is that you pass parameters to the
    command batch where you create the procedure. That does not fly. Nor
    would there be any point to so so.
    >
    But I completely agree with Stephany Young's analysis. That stored
    procedure is completely meaningless, so it's a good thing that
    you are not able to create it.
    >
    --
    Erland Sommarskog, SQL Server MVP, esq...@sommarsk og.se
    >
    Books Online for SQL Server 2005 athttp://www.microsoft.c om/technet/prodtechnol/sql/2005/downloads/books...
    Books Online for SQL Server 2000 athttp://www.microsoft.c om/sql/prodinfo/previousversion s/books.mspx
    Thanks for your help everyone.
    Of course the SP shown is a simple example of an SP. The actual SP
    does perform a vital task on our servers and does need to be there. I
    was simply having trouble getting the VB app to add it.

    Comment

    • Karl Rhodes

      #3
      Re: Dynamically create stored procedure in sql server from a vb.netwindows forms app

      On 30 May, 11:01, Karl Rhodes <googlegro...@c ortexa.co.ukwro te:
      On 29 May, 23:00, Erland Sommarskog <esq...@sommars kog.sewrote:
      >
      >
      >
      >
      >
      Karl Rhodes (googlegro...@c ortexa.co.uk) writes:
      When I run this and check SQL Profiler I see the text "exec
      sp_executesql N'" before the word "CREATE" and get the error
      "incorrect syntax near the keyword 'PROCEDURE'"
      >
      Can anyone see where I'm going wrong, or does anyone know how to
      dynamically create a stored procedure in a sql server database in this
      way?
      >
      The exact reason for the error is that you pass parameters to the
      command batch where you create the procedure. That does not fly. Nor
      would there be any point to so so.
      >
      But I completely agree with Stephany Young's analysis. That stored
      procedure is completely meaningless, so it's a good thing that
      you are not able to create it.
      >
      --
      Erland Sommarskog, SQL Server MVP, esq...@sommarsk og.se
      >
      Books Online for SQL Server 2005 athttp://www.microsoft.c om/technet/prodtechnol/sql/2005/downloads/books...
      Books Online for SQL Server 2000 athttp://www.microsoft.c om/sql/prodinfo/previousversion s/books.mspx
      >
      Thanks for your help everyone.
      Of course the SP shown is a simple example of an SP. The actual SP
      does perform a vital task on our servers and does need to be there. I
      was simply having trouble getting the VB app to add it.- Hide quoted text -
      >
      - Show quoted text -
      Just on quick note to say thanks to Stepheny... youre example worked a
      treat.

      Karl

      Comment

      Working...