Passing values to a SQL 6.5 Stored Procedure

Results 1 to 2 of 2

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
    Cable Guest

    Default RE: Passing values to a SQL 6.5 Stored Procedure

    I assume you are using code like this:<BR><BR>CREATE PROCEDURE emp_lookup @emp_num varchar(6) <BR>AS<BR><BR>SELECT emp_num, emp_name, emp_ssn, emp_addr<BR>FROM dbo.employee<BR>WHERE emp_num = @emp_num<BR>ORDER BY emp_name<BR>GO<BR><BR>Your SQL Query should then consist of:<BR><BR>s_SQL = "emp_lookup " & i_emp_num<BR><BR>Optionally you can use the EXEC if you&#039d like:<BR><BR>s_SQL = "EXEC emp_lookup " & i_emp_num<BR><BR>the i_emp_num is a variable where you store the employee number to lookup in Server Side VBScript. I just happened to call it i_emp_num but you can call it what you like. <BR><BR>then do a:<BR><BR>set rsreplist=conntemp1.Execute(s_SQL)<BR><BR>I usually store my SQL Queries as Strings. <BR>

Posting Permissions

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