I would like to put together a T-SQL script using Table A that has all of
the table names.
The T-SQL will read the table names and generate the sql statements to
indexes for these tables.
Table A will be in the same database as the tables that would like to create
the indexes. I know you can do this with SQL Server Manager from All Task-
>
Generate SQL Script, but I would like to automate this task.
Please help me with this task.
Thank You,You can find the names of all the tables and in your database in the
information_schema.tables view, and all the columns in the
information_schema.columns view.
Jacco Schalkwijk
SQL Server MVP
"Joe K." <Joe K.@.discussions.microsoft.com> wrote in message
news:5DD35EDB-0634-4A66-B4EE-04FDBD467BB4@.microsoft.com...
> I would like to put together a T-SQL script using Table A that has all of
> the table names.
> The T-SQL will read the table names and generate the sql statements to
> indexes for these tables.
> Table A will be in the same database as the tables that would like to
> create
> the indexes. I know you can do this with SQL Server Manager from All
> Task->
> Generate SQL Script, but I would like to automate this task.
>
> Please help me with this task.
> Thank You,
>|||Joe
You create an index on the column not on the Table. You have to know all
columns that you want to create an index. It is really important because if
you create redundant index or useless index it may lead to performance hit
of the query.
"Joe K." <Joe K.@.discussions.microsoft.com> wrote in message
news:5DD35EDB-0634-4A66-B4EE-04FDBD467BB4@.microsoft.com...
> I would like to put together a T-SQL script using Table A that has all of
> the table names.
> The T-SQL will read the table names and generate the sql statements to
> indexes for these tables.
> Table A will be in the same database as the tables that would like to
create
> the indexes. I know you can do this with SQL Server Manager from All
Task->
> Generate SQL Script, but I would like to automate this task.
>
> Please help me with this task.
> Thank You,
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment