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 2000 Forums
 Transact-SQL (2000)
 top 1 record

Author  Topic 

cognos79
Posting Yak Master

241 Posts

Posted - 2007-11-08 : 10:47:20
I want to assign the top 1 name returned to a variable. how do i do

select @name = top 1 [name] from Students

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-08 : 11:00:08
[code]select top 1 @name = name from Students[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

cognos79
Posting Yak Master

241 Posts

Posted - 2007-11-08 : 11:13:29
Thanks
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-09 : 01:51:27
quote:
Originally posted by cognos79

I want to assign the top 1 name returned to a variable. how do i do

select @name = top 1 [name] from Students


Using Order by clause will make sense

Madhivanan

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

- Advertisement -