Link to home
Start Free TrialLog in
Avatar of DOOM_DAEMON
DOOM_DAEMON

asked on

Create Stored Procedure in SQL2000 at Runtime

       I'm familiar with using SQL Server 2000. Also I'm a delphi-mania programmer too (Though I'm not an expert yet) I've created store Proceder in SQL Server 2000 using Enterprise Manager of SQL Server. I named it "spTest". Suppose that it's properties contain SQL statement like this
    "CREATE PROCEDURE [spTest] AS SELECT * FROM MYTABLE ORDER BY FIELD01"
    Then I drop TADOConnection named "AConMain" and TADOStoredProc named "spTEST" in the datamodule. I then set spTest.Connection to AConMain then what I must do next is to set spTEST.ProcedureName to "sptest" Object in SQL Server database ( I skip database name and I assume that you know how to do that) What I want to know is that if I want to Drop a procedure "spTest" and re-create in the same name but with difference SQL Statement, say, to be new statement to
    "CREATE PROCEDURE [spTest] AS SELECT * FROM MYTABLE ORDER BY FIELD02"
    In stead of Arrange by FIELD01, I prefer to Arrange dataset by FIELD02. And let my spTest component Reactivate to have dataset at hand but in difference order. What I don't know is how to do that without create stored procedure directly in Enterprise Manager. I think it's more flexible to do that in my programm.
    You please tell me and show me an example of code to do so, please. I'll return you my points. Thanks.
ASKER CERTIFIED SOLUTION
Avatar of JDN
JDN

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DOOM_DAEMON
DOOM_DAEMON

ASKER

      I found your comment very useful. I accept your comment and I would like to thanks to you. But please, if you have time, explain me how to create a certain questions that have variable pass to such stored procedure in case I have to pass something to it....