Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedure 2

Status
Not open for further replies.

sed10

Programmer
Feb 8, 2001
5
FR
Hello,
I am new in the world of SQL Server and I have a question that nobody yet could answer to me (sorry for my english, I am a Frenchy ;-) )
I develop a sp that generate a table of value from diferent tables, but, sometimes I make 3 times the same ask and it takes a while to get the result.
For example I would like to have only one line for those 2 :

Set @Case9 = (Select sum(Montant_TTC) FROM Factures_Rect
WHERE Ref_Mission=@IDMission)
Set @Case10 = (Select sum(Montant_TVA) FROM Factures_Rect
WHERE Ref_Mission=@IDMission)
As you can see I scan 2 times the table for the nearly same quest

Thank you for your help

 
Try this

Select @Case9 = sum(Montant_TTC),@Case10 = sum(Montant_TVA) FROM Factures_Rect
WHERE Ref_Mission=@IDMission
 
If I understand what you are trying to do, the following should work:

select @Case9 = sum(Montant_TTC),
@Case10 = sum(Montant_TVA)
from Factures_Rect
WHERE Ref_Mission=@IDMission

Hope this helps,

Chris Dukes
 
Well ColinM,

We must have done that at the same time!!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top