| Author |
Topic |
|
Eagle_f90
Constraint Violating Yak Guru
424 Posts |
Posted - 2006-07-20 : 13:53:52
|
| I am trying to create a stored procedure in SQL 2005 to pull a random row from a random table in a DB. I know how to pull the random row but now the random table. Is it possble to do that?-- If I get used to enving others...Those things about my self I pride will slowly fade away.-Stellvia |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-07-20 : 14:27:53
|
| Could U tell us how the "Random Table" looks like ??Srinika |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2006-07-20 : 20:04:10
|
| Srinika, what sort of stupid question is that ? Do you know what "random" means ? If you don't have anything useful to add to a thread like this, why bother ?Eagle, I do have to wonder why you would want to do that, it seems a bit pointless.Basically you are going to have to use some dynamic sql.Read this : http://www.sqlteam.com/item.asp?ItemID=4599and this : http://www.sqlteam.com/item.asp?ItemID=4619Now, all the info on the tables in your database is also stored in the database. You can query INFORMATION_SCHEMA.Tables to get a list of tables.So, you would need to pull a random row (you know how to do that) out of INFORMATION_SCHEMA.Tables to get a table name, then build dynamic sql to select * from it.Let us know how you go.Damian"A foolish consistency is the hobgoblin of little minds." - Emerson |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-07-20 : 21:42:40
|
| I need to select random rows from random tables in random databases on random servers running random RDBMS's to produce random reports to meet random requirements.Any ideas?CODO ERGO SUM |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2006-07-20 : 21:46:18
|
I think you need an infinite improbability drive.Actually, that's sounding a bit like my job at the moment Damian"A foolish consistency is the hobgoblin of little minds." - Emerson |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-20 : 21:47:16
|
quote: Originally posted by Michael Valentine Jones I need to select random rows from random tables in random databases on random servers running random RDBMS's to produce random reports to meet random requirements.Any ideas?CODO ERGO SUM
A random reader will read this post and randomly provide you a random solution KH |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-07-20 : 21:51:49
|
quote: Originally posted by khtan
quote: Originally posted by Michael Valentine Jones I need to select random rows from random tables in random databases on random servers running random RDBMS's to produce random reports to meet random requirements.Any ideas?CODO ERGO SUM
A random reader will read this post and randomly provide you a random solution KH
By then, my requirements will have randomly changed.CODO ERGO SUM |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-20 : 21:54:04
|
"By then, my requirements will have randomly changed."LOL !  KH |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2006-07-21 : 08:11:46
|
| Actually, this has a VERY simple solution. Get an SEP generator. Done and done.Help us help YOU!Read this blog entry for more details: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx*need more coffee*SELECT * FROM Users WHERE CLUE > 0(0 row(s) affected) |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-07-21 : 08:14:51
|
quote: Originally posted by Merkin Srinika, what sort of stupid question is that ?
Thank u Srinika |
 |
|
|
|