Thursday, February 3, 2011

Set a value from the top SQL

Hi Folks!!

 This is what something i have went wrong with. I wanted to set a value which was returning from the top clause,
 what i tried was
SELECT  @Variable = Top 1 <<column>> FROM <<table>>
Certainly that gave me errors .
So few searches from internet has solved my problem.

this was the solution for it.
SET @Variable =( SELECT   Top 1 <<column>> FROM <<table>>)

Njoy!




 

No comments:

Post a Comment