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.
| Author |
Topic |
|
superhero
Yak Posting Veteran
52 Posts |
Posted - 2007-01-29 : 08:11:21
|
| Hi thereI 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 CharactersFROM indexdata, containersWHERE (containercode = @containercode and indexdata.containerid = containers.containerid)select @sum=@@sumGO-->everything works fine up until the select @sum=@@sum bit - I'm not sure how to return the result to VB.ThanksD. |
|
|
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 containersON indexdata.containerid = containers.containeridWHERE containercode = @containercodeselect @sum=@@sumGO[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
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? |
 |
|
|
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 LarssonHelsingborg, Sweden |
 |
|
|
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. |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-01-29 : 08:32:36
|
| Remove the "AS Characters" part.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|