Solved

Alter a table, Order By ASC

Posted on 2013-02-01
3
276 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
[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
  • 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

734 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