Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-10
3
Medium Priority
?
330 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

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…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

618 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