Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Computed INdexes

Author  Topic 

xpandre
Posting Yak Master

212 Posts

Posted - 2013-11-25 : 15:25:40
Hi,

Can we create an index like below?


col1 is INT

create index ixtest1 on table1(cast(col1 as varchar))

Thanks
Sam

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2013-11-25 : 15:35:23
You can't do that, but you can index a computed column.

http://technet.microsoft.com/en-us/library/ms189292.aspx
Go to Top of Page

xpandre
Posting Yak Master

212 Posts

Posted - 2013-11-25 : 16:08:03
Thank you Lamprey..
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2013-11-25 : 19:27:27
Or create a VIEW (including the CAST) and index on that perhaps? (But I haven't tried it!)
Go to Top of Page
   

- Advertisement -