Solved

Alter a table, Order By ASC

Posted on 2013-02-01
3
273 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 65

Accepted Solution

by:
Jim Horn earned 500 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 65

Expert Comment

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

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

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…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

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