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)
 need stored procedure help ...

Author  Topic 

frank.svs
Constraint Violating Yak Guru

368 Posts

Posted - 2007-03-13 : 05:20:23
Hi pals,

I need a small help.
I have the following table.
create table test
(
empno int,
name varchar(10),
sal int
)

select * from test

101 frank 9999
102 alex 7777
103 raj 6666
104 sam 3333
105 tarun 1111
106 bobby 2222
107 jack 1234
108 sharat 2888
109 ram 9193
110 santhosh 3939


Now i need to write a stored procedure.Each time when i execute the stored procedure it should able to return 3 random recs from the table
each and every time i try to execute the stored procedure.

How can i do that. Can anyone plz help me.


Thanks in advance,
franky

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-13 : 07:48:24
[code]
select top 3 * from test order by newid()
[/code]


KH

Go to Top of Page
   

- Advertisement -