TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vijay Yadav
NA
1.4k
651.3k
Random number generation in sql
Jul 4 2011 10:46 AM
I want employees id to be fetched randomly by using the blow query
select Top 2 SessionId from Flash_Temp2
order by NEWID()
but instead of top 2, i want to pass it in a variable as its depend on the situation for ex:
declare @id int
set @id=3
select Top @id SessionId from Flash_Temp2
order by NEWID()
it givs following error:
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near '@id'.
Reply
Answers (
12
)
Arrange the SNO after Delete Query Execute
Assign single varible a multiple rows using Select query in stored procedure