Hi, I have googled this topic and I can't find an easy answer so I decided to come here and ask for an explanation on how I can do the following:
I am trying to declare and set variables = to table names and field names b.c I have a bunch of tables and I have to put unique indexes on fields in each table. I know all the sql to do it and I can replace the table names and field names for each table iteration I need to put the unique index on, but I was hoping I could it using a system table and assigning values to variables that way...but I don't know enough to do that.
Basically, I have a bunch of fact tables that have a surrogate primary key and another column representing something, i.e., employees, etc. I want to put a unique nonclustered index on each of thies fields (each field is a differnt name with different values from a different table) in about 10 different tables.
Ideally I would like a way to create a T-SQL statement that I would be able to assign values to variables and just replace maybe one or two lines of the T-SQL statment instead of 10 for each table. What system tables should I use for this? If that is in fact the correct path.
You want to put a unique nonclustered index on every column of every table? If not, how do you identify the ones you want this index on? Will it always be one column, or are some of these composite indexes? How many indexes in total?