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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to Use TOP in Query

Author  Topic 

khufiamalik
Posting Yak Master

120 Posts

Posted - 2008-08-21 : 04:14:09
Hello All,
I have a query like
SELECT TOP(1) Basic_Pay*60/100
from Table2


and i have to use it in SP and want to get the resultant value in a variable
so I made it like
Declare @output as varchar(2100)
SELECT @output = TOP(1) Basic_Pay*60/100 from Table2

But this query is giving me error.
Can any one tell me that how to use the above query???

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-21 : 04:15:08
SELECT TOP(1) @output = Basic_Pay*60/100 from Table2
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-21 : 04:15:34
SELECT TOP(1) @output = Basic_Pay*60/100 from Table2


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-21 : 04:16:47


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-21 : 04:18:52
quote:
Originally posted by madhivanan



Madhivanan

Failing to plan is Planning to fail


26 secs delay
Go to Top of Page
   

- Advertisement -