title: Dynamically name indexes in SQL Server 2005?
body: <p>As most people who work with Sql Server know, you can declare a temporary table like so:</p>
  
  <pre><code>create table #foo 
      (
      row_id int identity not null primary key,
      bar varchar(50) not null default 'YoMomma'
      );
  </code></pre>
  
  <p>...this will create a primary key and a default constraint on this temporary table; the names for these objects will be unique, dynamically created by Sql Server.</p>
  
  <p>Is it possible to create a dynamically named index for the table after it's been created?  I have a case where a stored procedure using temporary tables may be running multiple instances at the same time, and I'd like to increase the performance without risking a conflict between identically named objects in the tempdb database.  <code>CREATE INDEX</code> command requires an explicit index name.</p>
  
  <p>I am looking for a solution that does not involve dynamic SQL, just dynamic names.</p>