Author |
Topic |
hoangit
Starting Member
8 Posts |
Posted - 2012-02-06 : 01:56:53
|
use Northwindcreate procedure dbo.CalculateFreight @CustomerID nchar(5) , @total money output asselect @total = sum(Freight) from Orders where CustomerID = @CustomerIDdeclare @total money execute dbo.CalculateFreight @CustomerID='VINET' , @total output---------- Please help me with this error :Msg 137, Level 15, State 2, Line 1Must declare the scalar variable "@total".---------- I don't understand why I declared scalar variable but I cann't execute . Whay do i have to do ? Please help me execute it . |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-02-06 : 01:59:04
|
when you reference one of the parameter with name, you will need to do that for all paramtersexecute dbo.CalculateFreight @CustomerID='VINET' , @total = @total output KH[spoiler]Time is always against us[/spoiler] |
 |
|
hoangit
Starting Member
8 Posts |
Posted - 2012-02-06 : 03:47:51
|
I also cann't execute . Hic Hic . Please help me ! |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-02-06 : 03:55:24
|
quote: Originally posted by hoangit I also cann't execute . Hic Hic . Please help me !
what is the error messages ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
hoangit
Starting Member
8 Posts |
Posted - 2012-02-06 : 04:12:40
|
execute dbo.CalculateFreight @CustomerID='VINET' , @total = @total output . The same as first error . Cann't declare variable .>>>Msg 137, Level 15, State 2, Line 1Must declare the scalar variable "@total". |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-02-06 : 04:13:49
|
[code]declare @total money execute dbo.CalculateFreight @CustomerID='VINET' , @total = @total outputselect @total[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
hoangit
Starting Member
8 Posts |
Posted - 2012-02-06 : 04:20:41
|
when I highlight 2 lines : declare @total money execute dbo.CalculateFreight @CustomerID='VINET' , @total = @total output>>>>. It announce successfullybut I highlight one line : execute dbo.CalculateFreight @CustomerID='VINET' , @total = @total output>>>>It announce : Must be scalar variable |
 |
|
hoangit
Starting Member
8 Posts |
Posted - 2012-02-06 : 04:24:38
|
Thank you so much , I understood . We have to highlight all line when we will run it successfully . Thank you KHtan . You are so kind and intelligent |
 |
|
hoangit
Starting Member
8 Posts |
Posted - 2012-02-06 : 04:26:14
|
what is your yahoo ? Do i want to be your friend , KHtan ? |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-02-06 : 05:06:52
|
quote: Originally posted by hoangit when I highlight 2 lines : declare @total money execute dbo.CalculateFreight @CustomerID='VINET' , @total = @total output>>>>. It announce successfullybut I highlight one line : execute dbo.CalculateFreight @CustomerID='VINET' , @total = @total output>>>>It announce : Must be scalar variable
Yes. You need to declare the variable to hold the value return from the CalculateFreight procedure. The variable name does not necessary to be the same as the parameter name, for convenience, i just named it the same. KH[spoiler]Time is always against us[/spoiler] |
 |
|
hoangit
Starting Member
8 Posts |
Posted - 2012-02-06 : 05:46:46
|
Yes . I understood . Thanks you . Can you give me your yahoo ? |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-02-06 : 06:13:52
|
Sorry i don't use Yahoo KH[spoiler]Time is always against us[/spoiler] |
 |
|
hoangit
Starting Member
8 Posts |
Posted - 2012-02-06 : 06:34:27
|
what is your email ? I think I can ask you something in Java |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-02-06 : 07:08:10
|
Sorry, i don't know Java. It is would better and you will get better response if you ask it in a java forum KH[spoiler]Time is always against us[/spoiler] |
 |
|
|