Passing values to a SQL 6.5 Stored Procedure

Results 1 to 3 of 3

Thread: Passing values to a SQL 6.5 Stored Procedure

  1. #1
    Join Date
    Dec 1969
    Posts
    940

    Default Passing values to a SQL 6.5 Stored Procedure

    My question is simple. Can I write a stored procedure in SQL 6.5 and pass criteria to it? Like this:<BR>select * from table order by &variablepassed<BR><BR>If so can you provide some sample code for me, the stored procedure and the ASP to use with it. I currently just execute my stored procedures like this <BR>set rsreplist=conntemp1.Execute("sp_getreps")<BR><BR>T hanks all.<BR><BR>Eric

  2. #2
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: Passing values to a SQL 6.5 Stored Procedure

    You can create a stored procedure and pass variables to it, but you can&#039t order a select statement on one of these variables passed in. I&#039d recommend you read about CREATE PROCEDURE in the SQL books on-line.<BR><BR>Let&#039s say that you wanted to show the reps from the state MO.<BR><BR>CREATE PROCEDURE sp_getreps ( @State char(2) ) AS<BR>SELECT * FROM table WHERE State = @State<BR><BR>Then, in your ASP, you&#039d do:<BR>strState = "MO"<BR>Set rsRepList = ConnTemp1.Execute("sp_getreps " & strState)<BR><BR>Does that answer your question? I&#039d really recommend that you read up with the SQL books on-line. Happy Programming!

  3. #3
    Dynamic Guest

    Default RE: Passing values to a SQL 6.5 Stored Procedure

    Try this, it should provide a compact way of getting your result set from a stored procedure:<BR>&#060;%<BR>Dim dbHandle<BR>&#039Put ODBC connection code here and set it to dbHandle<BR>Dim sqlQuery, rsreplist, ReturnValue<BR><BR>sqlQuery = "sp_getreps " & variablepassed<BR>set rsreplist = dbHandle.Execute(sqlQuery) <BR>if not rsreplist.Eof then <BR> ReturnValue = rsQuery("field_name")<BR>rsreplist.close <BR>%&#062;<BR><BR>-Dynamic

Posting Permissions

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