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 |
|
balsoft
Starting Member
2 Posts |
Posted - 2009-04-16 : 06:30:54
|
| Hi I'm new at SQl, and i have a problem.If I use this piece of code as a Query SELECT SUM(ElectricityDailyUsage) as Answer FROM ElectricalUsageMy problem is how can I save the answer as a Variable or load the answer into a textbox.I.ve searched the Web but are unable to find the answerIf you can please help meBalsoft |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-16 : 06:53:04
|
| DECLARE @ElectricityDailyUsage INTSELECT @ElectricityDailyUsage=SUM(ElectricityDailyUsage) as AnswerFROM ElectricalUsageMake sure @ElectricityDailyUsage has datatype same as that of ElectricityDailyUsageMadhivananFailing to plan is Planning to fail |
 |
|
|
balsoft
Starting Member
2 Posts |
Posted - 2009-04-16 : 12:22:08
|
| Hi Madhivanan, thank you for your prompt reply.I should have said that I am accessing the database using my program in VB language from visual studio.Your code runs, but how do I access the variable so that I can use its value.If you have an answer please let me know - - Thank YouBalsoft |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-16 : 13:59:17
|
| you can make it a procedure with output parameter. then in your application use a variable to get the return value and then display it.http://www.a1vbcode.com/vbtip-118.asp |
 |
|
|
|
|
|