?
Solved

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

Posted on 2011-03-10
3
Medium Priority
?
329 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Accepted Solution

by:
quizwedge earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

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