Solved

Change the productID of my entire Product table according to clients changing ranking

Posted on 2011-03-10
3
322 Views
Last Modified: 2012-05-11
My web app presents an entire category of products displayed using (ORDER BY Product.ProductID).  My client wants to choose which products are side by side and/or at the top of the page. To add a Rank column to my product table would force the client to manually assign an integer to each product in his catalog. I am thinking there is a way to change the ProductID to accommodate him instead. Some way of reordering the table.  If anyone can help by either suggesting code or just tell me I am wasting my time, please do.
0
Comment
Question by:pathfinder8008
3 Comments
 
LVL 14

Accepted Solution

by:
quizwedge earned 500 total points
ID: 35098047
There's probably a better solution. If the product ID is only used in the one table, then this might be doable without it being a major pain. If you have to update orders, etc. you're running the risk of corrupting data or, at best, having a lot of data to update. The other problem comes in when you add in more products. If you already have product 1, 2, and 3 and the customer wants to put 4 in between 1 and 2 you'll have to renumber again.

What about using your Rank idea, but with a modification? By default, rank is Null. In your query, you can do IsNull(Rank, 999999) (or some other large number). Then sort by Rank, ProductID. Anything with Null will show up at the end.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35098140
you shouldn't mess about with ID. The ID is there to uniquely identify each record, if you want to force an particular order then you would be better with a separate column to accomodate that.
0
 

Author Closing Comment

by:pathfinder8008
ID: 35099381
Thanks quizwedge, I added the Rank column and used (ORDER BY IsNull(Rank, 9999), Product.ProductID) to my SELECT ROW_NUMBER() and it works great. This solution will not over tax my client.  And yes, carl tawn you are absolutely correct about messing with the uniqueID. It was clutching at straws.  Thanks again to the pros at EE.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question