November 13, 2009 at 3:19 am
I have a problem. I want to concantenate an index in sql server 2005, i.e. i want it to look something like this:
CREATE INDEX IND_SEARCH ON TAB_HOCKEYTEAMS
(
COLUMN1+COLUMN2
)
That gives me an syntax error. It works in Oracle, allthough you have to change the "+" to "||"...
Is there anyway of doing this? Are there any other options?
Tnx!! 🙂
November 13, 2009 at 3:44 am
Just use a comma instead of a plus
CREATE INDEX IND_SEARCH ON TAB_HOCKEYTEAMS
(
COLUMN1,COLUMN2
)
November 13, 2009 at 4:41 am
But I want the index to treat these two columns as one... When i do it like that, I will still get two columns seperated in the index.
November 13, 2009 at 4:49 am
Can you explain in detail what you are trying to achieve?
I'm trying to fgure out why you would want them treated as a single column?
November 13, 2009 at 5:12 am
Danspojken (11/13/2009)
But I want the index to treat these two columns as one...
Why?
If you want to do that, create a calculated column in the table, persist the column and then index that. Be aware that it'll only be of use if you have queries that concatenate the two columns before doing a comparison (which is usually a bad practice in the first place)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply