用TStoredProcStoredProc1.ParamByName('@Forumtablename').asstring :='dfafafdasfdasf';
StoredProc1.execsql;edit1.text:= StoredProc1.ParamByName('@Forumtablename').asstring 

解决方案 »

  1.   

      在Delphi中我会调用,我是问在SQL中怎么把上面的存储过程的写法转为用exec来写。  newyj你写的Delphi语句和上面的存储过程配合执行,有错误。
      存储过程中@Forumtablename是个变量,它是不能直接跟在from后面的。
      

  2.   

    CREATE PROCEDURE Forum_GetMaxID
    @MaxMainID int Output  ,
    @Forumtablename char(30)
    as
    declare @csql char(255)
    set nocount on
    set @csql ='select '+@MaxPhysicsID'+'=max(physicsID) , '+ @MaxMainID+
      '=max(mainID) from' + @Forumtablename + CHAR(10) +char(13)+
      'if '+@MaxMainID+' is null select '+@MaxMainID+'=0'
    execute(@csql)
      

  3.   

    exec Forum_GetMaxID @MaxPhysicsID=参数1,@Forumtablename=参数2
      

  4.   

    with Query1 do
    begin
      SQL.Text :=
        'declare @Param1 varchar(100)' + #13 +
        'exec Forum_GetMaxID @Param1 output, ''Param2Value''' + #13 +
        'select @Param1';
      Open;
      ShowMessage('this store result Value: ' + Fields[0].AsString);
    end;可以直接到Query Analyzer执行SQL.Text的内容。