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.
Author |
Topic |
ranjith
Starting Member
2 Posts |
Posted - 2006-09-22 : 07:04:35
|
Dear ALL,Please suggest how to implement RANK feature in SQL Server 2000.That should be Table independent.Thanks in advanceRanjith |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-22 : 07:28:53
|
What du you mean with independent?Not even in SQL Server 2005 is RANK table independent. You must know what table you are working with, and which column, to get RANK.Peter LarssonHelsingborg, Sweden |
 |
|
ranjith
Starting Member
2 Posts |
Posted - 2006-09-22 : 07:38:23
|
Hi Peso,I have written a function for the same but I have to give Table,Column to be Ranked and Top number of rows to be retrive.I wants to have a generic function which can take parameters as Table,Column.And this function needs to work in both SQL Server 2000 and SQL Server 2005Please suggest.Ranjith |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2006-09-22 : 08:20:37
|
quote: Originally posted by ranjith Hi Peso,I have written a function for the same but I have to give Table,Column to be Ranked and Top number of rows to be retrive.I wants to have a generic function which can take parameters as Table,Column.And this function needs to work in both SQL Server 2000 and SQL Server 2005Please suggest.Ranjith
This is not how functions should work! In fact, it is not valid in SQL Server -- functions cannot use dynamic code. Table and column names should not be variable for a given function or stored procedure, they should be constants. Only your data itself should vary and be passed as parameters. If you have data stored in many tables that is all of the same type (i.e., if you have 1 table of Orders per customer) then they should all be in the same table.It would be much better for you to step back and explain to us what you are trying to do and why you feel you need this. Hopefully it is not too late and we can help you fix your design to make things much, much easier and to follow best practices and to normalize your data.- Jeff |
 |
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|
|