Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 using EXEC

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-09-22 : 08:41:23
Anthony writes "Hello, I am trying to construct dynamic SQL Query for Stored Procedure, something like this:
CREATE PROCEDURE sp_PagedItems
(
@id int
)
AS
CREATE TABLE #TempItems
(
-- attributes of table1
)

DECLARE @strSQL varchar(30)
SELECT @strSQL = "SELECT * FROM table1 WHERE id <= '"
+ @id + "'"

INSERT INTO #TempItems
EXEC(@strSQL)

/* and the rest of the code */

The result of this query will be put in a table called
"TempItems". However, I got error message when in ASP code
I type:
sql = "sp_PagedItems " & Session("ID")
objRS.Open sql, conn

Assume ASP code is correct and can connect to the database"
   

- Advertisement -