Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Rename tables and Build Indexes Dynamically in SQL

$
0
0

I have a need for a stored procedure , where user can pass the tablename,schemaname and indexname as input variables.

Then the stored procedure should accept those as input variables and do the foll steps: The tblname, fieldname and indxes can change .

  1. Rename existing tableA to tableA _PREV
  2. Select top 0 * into tableA From tableA _PREV
  3. Create clustered, unique Index on FieldA Such as CREATEuniqueCLUSTERED INDEX [IndexName]  

    ON dbo.TableA (FieldName);

    GO


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>