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 help with Data Randomizer

Author  Topic 

krainov
Yak Posting Veteran

57 Posts

Posted - 2008-10-02 : 08:03:47
Hi!
I need to display a UserControl on the main page which will show the images key words from DB randomly. The key words are stored in table as NvarChar ('key word' space 'keyword' and so on) There can be a 10 or more key words for 1 image stored in table. How can I retrieve them from Table in random order?



spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-10-02 : 08:22:44
select ...
from yourTable
order by newid()

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page

krainov
Yak Posting Veteran

57 Posts

Posted - 2008-10-02 : 08:36:50
And what about arranging these keywords into 1 string? Is it possible?
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-10-02 : 08:45:42
you should really do that on the client side.

but if you must do it on the sql server side then you can use this:
http://weblogs.sqlteam.com/mladenp/archive/2007/06/01/60220.aspx

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page
   

- Advertisement -