How can I add Descending Sorting Index within a SQL Statement when creating a table

accesser2003

Registered User.
Local time
Tomorrow, 01:41
Joined
Jun 2, 2007
Messages
124
I built a table [EmployeesAttendanceReportSource_Normal] using the SQL Statement as shown below. What I need is to add a descending sorting index for the column [AttDay].

How to rewrite this SQL statement to achieve this:


CREATE TABLE [dbo].[EmployeesAttendanceReportSource_Normal] (
[Indx] [int] NULL ,
[Department] [nvarchar] (90) NULL,
[ShortDay] [nvarchar] (50) NULL,
[AttDay] [SmallDateTime] NULL,
[ID] [int] NOT NULL
) ON [PRIMARY]
GO


ALTER TABLE [dbo].[EmployeesAttendanceReportSource_Normal] WITH NOCHECK ADD
CONSTRAINT [PK_EmployeesAttendanceReportSource_Normal] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY]
GO

GRANT REFERENCES , SELECT , UPDATE , INSERT , DELETE ON [dbo].[EmployeesAttendanceReportSource_Normal] TO [public]
GO
 
Can't you just click on the column header and go to Records > Sort > Sort Descending? And then save the table?
 
I am talking about making SQL server table using SQL statement. How can I make it?
 
I don't think it can be done in the actual create table statement, you'd need a seperate create index statement.

http://msdn.microsoft.com/en-us/library/ms188783.aspx

CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
ON <object> ( column [ ASC | DESC ] [ ,...n ] )
[ INCLUDE ( column_name [ ,...n ] ) ]
[ WITH ( <relational_index_option> [ ,...n ] ) ]
[ ON { partition_scheme_name ( column_name )
| filegroup_name
| default
}
]
[ ; ]
 

Users who are viewing this thread

Back
Top Bottom