Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indexes Computed Fields

Status
Not open for further replies.

MrGandalf

Programmer
Joined
Jul 19, 2005
Messages
35
Location
NL
Hi all,

Is it possible to create computed indexes in SQL Server 2000?

For example you have a table client with fields clientnr, name, postal. I want an index on clientnr+name+postal instead of clientnr, name , postal.



 
I'm not sure what you mean by computed indexes.

It is possible to create a combined Index in SQL 2000 of multiple columns. Either use the Table Design in Enterprise Manager, go to the Index tab and you can add multiple columns there, or use T-SQL.

The T-SQL syntax is as follows:

Code:
CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX 
<MyIndex> 
ON MyTable 
( column1 [ ASC | DESC ], Column2, Column3 )




Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
 
What I mean is this.

I have an SQL.

Select * from clientnr where clientnr+name+postal=x+y+z

If I have made an index on the table: clientnr,name, postal then the above sql will not use this index. I have to create an index: clientnr+name+postal rather than clientnr,name,postal.

 
How about computed column instead?

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Is possible, but not my first choice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top