Click here to Skip to main content
15,921,840 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hello Everyone,
Today I read somewhere that using index means improving your application performance.
It sounds great but I stuck in simple problem.

I have 1 Column which has nvarchar(MAX) datatype and contains around 30k records.
Records are already sorted in ascending.

I tried to put index by using Indexing dialog. but I didnt find out nvarchar column. I got only columns which has integer as datatype.

1) Does indexs support NVARCHAR datatype?
2) Do I really need to add index on column which is already sorted?

Regards
Rohit More
Posted

1 solution

First the data (already sorted? I doubt it), anyway ...
CREATE TABLE [cpqa].[tbl_RM_maxNvarchar](
	[data][nvarchar](323)
	)
INSERT INTO [cpqa].[tbl_RM_maxNvarchar]
	VALUES('transworldairlines')

Now the target for an indexed version of that "sorted" table.
CREATE TABLE [cpqa].[tbl_RM_maxNvarcharX](
	[x][int]IDENTITY(1,1),
		[data][nvarchar](323)
		)
INSERT INTO [cpqa].[tbl_RM_maxNvarcharX]
	SELECT * FROM [cpqa].[tbl_RM_maxNvarchar]

Execute this query:
SELECT * FROM [cpqa].[tbl_RM_maxNvarcharX]

And get this result:
x   data
~~~~~~~~~~~~~~~~~~~~~~~
1   transworldairlines

And finally sort using ORDER BY [x] ASC.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900