views:

52

answers:

2

I am writing a stored procedure like this..

declare @avg float
set @avg = select avg(rating) from videorating where videoid = 4

Can I write it like this? Can I store the value in @avg?

+3  A: 

I would write it

declare @avg float
select @avg=avg(rating) from videorating where videoid = 4
Michael Todd
+1: Beat me to it
OMG Ponies
(Which is bloody amazing...you're like the king of SQL. And fast.)
Michael Todd
thank you Mr.Michael Todd
Surya sasidhar
Not a problem. Glad I could help.
Michael Todd
@Michael Todd: Quassnoi's faster - even his wife says so ;) :D
OMG Ponies
A: 

Yes. You can

bkm
thank you Mr. bkm thank you for response
Surya sasidhar
**No**. You can't. http://msdn.microsoft.com/en-us/library/ms189499.aspx
Michael Petrotta