Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Alter a table, Order By ASC

Posted on 2013-02-01
3
Medium Priority
?
280 Views
Last Modified: 2013-02-01
Is it possible to add a constraint to a table column that would sort based on date?
I'm using a uniqueidentifer as my primary key, so I want to order by ascending date on SubmitDate column.

ALTER TABLE MyTableName
ADD Constraint ORDER BY (SubmitDate)

SubmitDate is the column name.

I'm using SQL Server.

Thanks.
0
Comment
Question by:javierpdx
  • 2
3 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 38845615
Nope nope nope nope nope.
Tables are only containers of data, and do not contain logic that deals with how that data is sorted.

To view a sorted table, create a view that has

SELECT TOP 100 PERCENT whatever
FROM MyTableName
ORDER BY SubmitDate

btw long story where TOP must be in a view, just trust me on this one..
0
 

Author Closing Comment

by:javierpdx
ID: 38845620
Thanks.
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 38845625
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

916 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