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)
 Return value from Stored Procedure

Author  Topic 

superhero
Yak Posting Veteran

52 Posts

Posted - 2007-01-29 : 08:11:21
Hi there

I asked a question last week about counting actual characters in SQL. Now I need to know how I should write the stored procedure to return the SUM value to VB.net 2.0.

I tried this but SQL 2000 tells me that I also need to declare @@sum - so @@sum is obviously the wrong thing to use. Any help would be much appreciated.

CREATE Procedure CountCharactersInContainer
(@containercode int, @sum int output)
as

SELECT SUM(LEN(containercode) + LEN(indexfield1) + LEN(indexfield3) + LEN(indexfield4) + LEN(indexfield5) + LEN(indexfield6) + LEN(indexfield7)) AS Characters
FROM indexdata, containers
WHERE (containercode = @containercode and indexdata.containerid = containers.containerid)

select @sum=@@sum
GO

-->everything works fine up until the select @sum=@@sum bit - I'm not sure how to return the result to VB.

Thanks

D.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-29 : 08:16:15
[code]CREATE Procedure CountCharactersInContainer
(@containercode int, @sum int output)
as

SELECT @sum = SUM(LEN(containercode) + LEN(indexfield1) + LEN(indexfield3) + LEN(indexfield4) + LEN(indexfield5) + LEN(indexfield6) + LEN(indexfield7))
FROM indexdata JOIN containers
ON indexdata.containerid = containers.containerid
WHERE containercode = @containercode

select @sum=@@sum
GO[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

superhero
Yak Posting Veteran

52 Posts

Posted - 2007-01-29 : 08:21:07
Harsh, when I try that I get "incorrect syntax near keyword 'AS'. That's the AS by "AS Characters"

What am I doing wrong?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-29 : 08:30:21
If you tried Harsh's suggestion, you would have noticed that he dropped the "as" part completely.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

superhero
Yak Posting Veteran

52 Posts

Posted - 2007-01-29 : 08:31:25
Yeah I saw just after I posted - sorry about that. It's working thanks guys.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-29 : 08:32:36
Remove the "AS Characters" part.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -