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 2000 Forums
 SQL Server Development (2000)
 Decalre Index?

Author  Topic 

cidr
Posting Yak Master

207 Posts

Posted - 2010-10-20 : 04:32:01
Hi there,

Hope everyones fine

Does anyone know if it's possible to create indexes by using a varible, for example:



DECLARE @Index VARCHAR(8)
SET @Index = 'Column'

CREATE NONCLUSTERED INDEX [IX_EXAMPLE] ON dbo.tblExample
(
@Index ASC
)WITH FILLFACTOR = 100 ON [PRIMARY]



The code obviously doesn't work but just wanted to see if there's anyway of similar?

Thanks for anyhelp in advance:)

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-20 : 04:50:01
Read for dynamic sql.
http://www.sommarskog.se/dynamic_sql.html


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

cidr
Posting Yak Master

207 Posts

Posted - 2010-10-20 : 05:18:06
Thanks Webfred! Forgot about dynamic sql
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-20 : 05:51:23
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -