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
 Transact-SQL (2000)
 Retrieving a Value from a Stored Procedure

Author  Topic 

jweiss
Starting Member

1 Post

Posted - 2003-01-12 : 09:57:27
I've got a stored procedure that takes an array, loops through it adding each value to a temp table then compares the contents of the temp table with another table and counts the number of records that are equal. The code snip below is where it actually compares the tables and counts the matches. The stored proc works fine in Query Analyzer, btw.

-----
select count(*) from #zip a, zip_tbl b where a.zip = b.zipcode
-----
(full stored proc can be found at http://www.whatsmyhomevalue.com/zipexists.txt)

Now what I'm trying to do is to get it to pass the count here back to the page that called it so that I can do...

if R(0) <> 0 then
bla bla bla
end if

For some reason, all it's passing back is the Return Code which is always 0 (thankfully). I've got several other stored procs that have a similar line of code at the end and they all pass the results back as a recordset just fine.

Any help would be appriciated, as I've been staring at this for 3 days now with no progress. I'm sure it something simple that I'm overlooking. Thanks.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-01-12 : 10:04:30
An ouput variable might be what you need:

http://www.sqlteam.com/item.asp?ItemID=2644

You can also use this technique to parse all the values in one operation, if you want:

http://www.sqlteam.com/item.asp?ItemID=2652

Go to Top of Page
   

- Advertisement -