Showing posts with label indexes. Show all posts
Showing posts with label indexes. Show all posts

Monday, March 26, 2012

Generic question about leaf-level of non-clustered indexes

In the case of a heap, I understand the leaf-level contains some sort
of RowId which points directly to the right page in the table. Good,
pretty quick.
If the table contains a clustered index, I understand this is what's
used as bookmark in all the non-clustered indexes of that table.
Question:
Couldn't this be extremely inefficient if the clustered index is not
unique?
If I created a non unique clustered index on a (small) column with low
selectivity, I might end up with thousands of rows for each value in
the clustered index.
Then a bookmark on such a value does not seem too good, does it?
I suppose there would be several pages read before reaching the actual
data page...
Thanks
EricThis is a multi-part message in MIME format.
--=_NextPart_000_00F4_01C3777E.0F0200C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Under the covers, it builds a "uniqueifier", so that all "keys" in the =clustered index are unique, even if you created it on a non-unique =column.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Eric Mamet" <eric_mamet_test@.yahoo.co.uk> wrote in message =news:11269dcb.0309100520.6d6a4e1f@.posting.google.com...
In the case of a heap, I understand the leaf-level contains some sort
of RowId which points directly to the right page in the table. Good,
pretty quick.
If the table contains a clustered index, I understand this is what's
used as bookmark in all the non-clustered indexes of that table.
Question: Couldn't this be extremely inefficient if the clustered index is not
unique?
If I created a non unique clustered index on a (small) column with low
selectivity, I might end up with thousands of rows for each value in
the clustered index.
Then a bookmark on such a value does not seem too good, does it?
I suppose there would be several pages read before reaching the actual
data page...
Thanks
Eric
--=_NextPart_000_00F4_01C3777E.0F0200C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Under the covers, it builds a ="uniqueifier", so that all "keys" in the clustered index are unique, even if you created =it on a non-unique column.
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"Eric Mamet" wrote in message news:11269d=cb.0309100520.6d6a4e1f@.posting.google.com...In the case of a heap, I understand the leaf-level contains some sortof =RowId which points directly to the right page in the table. Good,pretty quick.If the table contains a clustered index, I understand this =is what'sused as bookmark in all the non-clustered indexes of that table.Question: Couldn't this be extremely inefficient if =the clustered index is notunique?If I created a non unique clustered =index on a (small) column with lowselectivity, I might end up with =thousands of rows for each value inthe clustered index.Then a bookmark on =such a value does not seem too good, does it?I suppose there would be =several pages read before reaching the actualdata page...ThanksEric

--=_NextPart_000_00F4_01C3777E.0F0200C0--|||This is a multi-part message in MIME format.
--=_NextPart_000_0037_01C3782F.68E72280
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
To add to Tom's comments, From memory this will add four bytes to the =size of your field for the subsequent non unique values. Plus an =addition two bytes because you now have a non fixed length column. As =you can see the extra overhead can be huge on something like an INT. If =there is another column you can add to the clustered index that can make =it unique, then I would consider this as it may actually use less space. = I.e. two INTs unique may use less space that one INT with low =selectivity.
-- Barry McAuslin
Crucis Technical Solutions Limited
support@.sqlfe.com
http://www.sqlfe.com
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:exfAK%235dDHA.568@.TK2MSFTNGP11.phx.gbl...
Under the covers, it builds a "uniqueifier", so that all "keys" in the =clustered index are unique, even if you created it on a non-unique =column.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Eric Mamet" <eric_mamet_test@.yahoo.co.uk> wrote in message =news:11269dcb.0309100520.6d6a4e1f@.posting.google.com...
In the case of a heap, I understand the leaf-level contains some sort
of RowId which points directly to the right page in the table. Good,
pretty quick.
If the table contains a clustered index, I understand this is what's
used as bookmark in all the non-clustered indexes of that table.
Question: Couldn't this be extremely inefficient if the clustered index is not
unique?
If I created a non unique clustered index on a (small) column with low
selectivity, I might end up with thousands of rows for each value in
the clustered index.
Then a bookmark on such a value does not seem too good, does it?
I suppose there would be several pages read before reaching the actual
data page...
Thanks
Eric
--=_NextPart_000_0037_01C3782F.68E72280
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

To add to Tom's comments, From memory =this will add four bytes to the size of your field for the subsequent non unique =values. Plus an addition two bytes because you now have a non fixed length =column. As you can see the extra overhead can be huge on something like an =INT. If there is another column you can add to the clustered index that can =make it unique, then I would consider this as it may actually use less =space. I.e. two INTs unique may use less space that one INT with low selectivity.
-- Barry McAuslin
Crucis Technical Solutions Limited
support@.sqlfe.comhttp://www.sqlfe.com">http://www.sqlfe.com
"Tom Moreau" = wrote in message news:exfAK%235dDHA.5=68@.TK2MSFTNGP11.phx.gbl...
Under the covers, it builds a ="uniqueifier", so that all "keys" in the clustered index are unique, even if you created =it on a non-unique column.
-- Tom

=---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql


"Eric Mamet" wrote in message news:11269d=cb.0309100520.6d6a4e1f@.posting.google.com...In the case of a heap, I understand the leaf-level contains some =sortof RowId which points directly to the right page in the table. Good,pretty quick.If the table contains a clustered index, I understand =this is what'sused as bookmark in all the non-clustered indexes of that table.Question: Couldn't this be extremely inefficient if =the clustered index is notunique?If I created a non unique =clustered index on a (small) column with lowselectivity, I might end up with =thousands of rows for each value inthe clustered index.Then a bookmark on =such a value does not seem too good, does it?I suppose there would be =several pages read before reaching the actualdata page...ThanksEric =

--=_NextPart_000_0037_01C3782F.68E72280--|||This question bothered me and it makes much more sense now.
Thanks very much to both of you.

Sunday, February 26, 2012

Generate Script in SQL 2005

In SQL2K, we can generate scripts just for PK and FK, or just Indexes.
Somehow, I could not to do that in SQL 2005, it does not give me the options
to generate only Indexes.
Any idea?This is a severe shortcoming in the tool (both not being able to right-click
the indexes node under a table and script all, and not being able to select
multiple items anywhere in Object Explorer). But thankfully, there is help
coming soon with Service Pack 2, which swaps out the Summary tab for a new
context-sensitive tab called Object Explorer Details. In this tab, when you
expand a table and highlight the Indexes node on the left, you can select
multiple items on the right, right-click them, and follow a Script > menu.
I talked about this briefly here:
http://www.aaronbertrand.com/rant.asp?r=499
"TBoon" <allblacks15@.hotmail.com> wrote in message
news:uo0a3dODHHA.4404@.TK2MSFTNGP03.phx.gbl...
> In SQL2K, we can generate scripts just for PK and FK, or just Indexes.
> Somehow, I could not to do that in SQL 2005, it does not give me the
> options to generate only Indexes.
> Any idea?
>|||In addition to Aaron's, post:
Meanwhile, consider doing some SMO coding: http://www.karaszi.com/SQLServer/info_generate_script.asp
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"TBoon" <allblacks15@.hotmail.com> wrote in message news:uo0a3dODHHA.4404@.TK2MSFTNGP03.phx.gbl...
> In SQL2K, we can generate scripts just for PK and FK, or just Indexes.
> Somehow, I could not to do that in SQL 2005, it does not give me the options to generate only
> Indexes.
> Any idea?
>|||Hi,Aaron
Hmm, it is possible that I do not understand you , but I can highlight more
than one item (SPfor example) in Object Explorer and script them out to the
new window
I have SQL Server 2005 Dev Edition
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:%23GNKeHPDHHA.3524@.TK2MSFTNGP06.phx.gbl...
> This is a severe shortcoming in the tool (both not being able to
> right-click the indexes node under a table and script all, and not being
> able to select multiple items anywhere in Object Explorer). But
> thankfully, there is help coming soon with Service Pack 2, which swaps out
> the Summary tab for a new context-sensitive tab called Object Explorer
> Details. In this tab, when you expand a table and highlight the Indexes
> node on the left, you can select multiple items on the right, right-click
> them, and follow a Script > menu.
> I talked about this briefly here:
> http://www.aaronbertrand.com/rant.asp?r=499
>
>
>
> "TBoon" <allblacks15@.hotmail.com> wrote in message
> news:uo0a3dODHHA.4404@.TK2MSFTNGP03.phx.gbl...
>> In SQL2K, we can generate scripts just for PK and FK, or just Indexes.
>> Somehow, I could not to do that in SQL 2005, it does not give me the
>> options to generate only Indexes.
>> Any idea?
>|||I don't know how you could do that. When I click on an object like a table,
and hold shift or control to try and click a second table, the second table
is highlighted (even if I am still holding shift or control).
Maybe you could take a screen shot of what you are talking about, because I
don't know of any node in Object Explorer that allows this (SP2 or prior).
We're talking about Management Studio here, right? Not Query Analyzer?
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23B5w9lSDHHA.3228@.TK2MSFTNGP03.phx.gbl...
> Hi,Aaron
> Hmm, it is possible that I do not understand you , but I can highlight
> more than one item (SPfor example) in Object Explorer and script them out
> to the new window
> I have SQL Server 2005 Dev Edition|||Hi ,Aaron
> We're talking about Management Studio here, right? Not Query Analyzer?
Sure , here is the morning , but I had already two coffees :-))))))
>I don't know how you could do that. When I click on an object like a
>table, and hold shift or control to try and click a second table, the
>second table is highlighted (even if I am still holding shift or control).
In Summery Tab I click on SP --hold Ctrl button and then secon SP --
I can send you a print screen if you want , just tell me the email address
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:ONxNC3SDHHA.3524@.TK2MSFTNGP06.phx.gbl...
>I don't know how you could do that. When I click on an object like a
>table, and hold shift or control to try and click a second table, the
>second table is highlighted (even if I am still holding shift or control).
> Maybe you could take a screen shot of what you are talking about, because
> I don't know of any node in Object Explorer that allows this (SP2 or
> prior).
> We're talking about Management Studio here, right? Not Query Analyzer?
>
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:%23B5w9lSDHHA.3228@.TK2MSFTNGP03.phx.gbl...
>> Hi,Aaron
>> Hmm, it is possible that I do not understand you , but I can highlight
>> more than one item (SPfor example) in Object Explorer and script them out
>> to the new window
>> I have SQL Server 2005 Dev Edition
>|||> In Summery Tab
(!) I was talking about Object Explorer (the left pane). I never used the
Summary Tab.
And as luck would have it, I don't have a pre-SP2 server within reach to
even see what you're talking about. Again, I was talking about in Object
Explorer, which I had initially expected to allow you to select multiple
objects.
A|||Ok,
I was confused by your statement
<coming soon with Service Pack 2, which swaps out the >Summary tab for a new
> context-sensitive tab called Object Explorer Details.
Well, I just wanted to say that on the righ pane (Summary Tab) you can do
that
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:e0aKhcXDHHA.1196@.TK2MSFTNGP02.phx.gbl...
>> In Summery Tab
> (!) I was talking about Object Explorer (the left pane). I never used the
> Summary Tab.
> And as luck would have it, I don't have a pre-SP2 server within reach to
> even see what you're talking about. Again, I was talking about in Object
> Explorer, which I had initially expected to allow you to select multiple
> objects.
> A
>

Generate Script in SQL 2005

In SQL2K, we can generate scripts just for PK and FK, or just Indexes.
Somehow, I could not to do that in SQL 2005, it does not give me the options
to generate only Indexes.
Any idea?This is a severe shortcoming in the tool (both not being able to right-click
the indexes node under a table and script all, and not being able to select
multiple items anywhere in Object Explorer). But thankfully, there is help
coming soon with Service Pack 2, which swaps out the Summary tab for a new
context-sensitive tab called Object Explorer Details. In this tab, when you
expand a table and highlight the Indexes node on the left, you can select
multiple items on the right, right-click them, and follow a Script > menu.
I talked about this briefly here:
http://www.aaronbertrand.com/rant.asp?r=499
"TBoon" <allblacks15@.hotmail.com> wrote in message
news:uo0a3dODHHA.4404@.TK2MSFTNGP03.phx.gbl...
> In SQL2K, we can generate scripts just for PK and FK, or just Indexes.
> Somehow, I could not to do that in SQL 2005, it does not give me the
> options to generate only Indexes.
> Any idea?
>|||In addition to Aaron's, post:
Meanwhile, consider doing some SMO coding: http://www.karaszi.com/SQLServer/in...rate_script.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"TBoon" <allblacks15@.hotmail.com> wrote in message news:uo0a3dODHHA.4404@.TK2MSFTNGP03.phx.gb
l...
> In SQL2K, we can generate scripts just for PK and FK, or just Indexes.
> Somehow, I could not to do that in SQL 2005, it does not give me the optio
ns to generate only
> Indexes.
> Any idea?
>|||Hi,Aaron
Hmm, it is possible that I do not understand you , but I can highlight more
than one item (SPfor example) in Object Explorer and script them out to the
new window
I have SQL Server 2005 Dev Edition
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in mess
age
news:%23GNKeHPDHHA.3524@.TK2MSFTNGP06.phx.gbl...
> This is a severe shortcoming in the tool (both not being able to
> right-click the indexes node under a table and script all, and not being
> able to select multiple items anywhere in Object Explorer). But
> thankfully, there is help coming soon with Service Pack 2, which swaps out
> the Summary tab for a new context-sensitive tab called Object Explorer
> Details. In this tab, when you expand a table and highlight the Indexes
> node on the left, you can select multiple items on the right, right-click
> them, and follow a Script > menu.
> I talked about this briefly here:
> http://www.aaronbertrand.com/rant.asp?r=499
>
>
>
> "TBoon" <allblacks15@.hotmail.com> wrote in message
> news:uo0a3dODHHA.4404@.TK2MSFTNGP03.phx.gbl...
>|||I don't know how you could do that. When I click on an object like a table,
and hold shift or control to try and click a second table, the second table
is highlighted (even if I am still holding shift or control).
Maybe you could take a screen shot of what you are talking about, because I
don't know of any node in Object Explorer that allows this (SP2 or prior).
We're talking about Management Studio here, right? Not Query Analyzer?
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23B5w9lSDHHA.3228@.TK2MSFTNGP03.phx.gbl...
> Hi,Aaron
> Hmm, it is possible that I do not understand you , but I can highlight
> more than one item (SPfor example) in Object Explorer and script them out
> to the new window
> I have SQL Server 2005 Dev Edition|||Hi ,Aaron
> We're talking about Management Studio here, right? Not Query Analyzer?
Sure , here is the morning , but I had already two coffees :-))))))

>I don't know how you could do that. When I click on an object like a
>table, and hold shift or control to try and click a second table, the
>second table is highlighted (even if I am still holding shift or control).
In Summery Tab I click on SP --hold Ctrl button and then secon SP --
I can send you a print screen if you want , just tell me the email address
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in mess
age
news:ONxNC3SDHHA.3524@.TK2MSFTNGP06.phx.gbl...
>I don't know how you could do that. When I click on an object like a
>table, and hold shift or control to try and click a second table, the
>second table is highlighted (even if I am still holding shift or control).
> Maybe you could take a screen shot of what you are talking about, because
> I don't know of any node in Object Explorer that allows this (SP2 or
> prior).
> We're talking about Management Studio here, right? Not Query Analyzer?
>
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:%23B5w9lSDHHA.3228@.TK2MSFTNGP03.phx.gbl...
>|||> In Summery Tab
(!) I was talking about Object Explorer (the left pane). I never used the
Summary Tab.
And as luck would have it, I don't have a pre-SP2 server within reach to
even see what you're talking about. Again, I was talking about in Object
Explorer, which I had initially expected to allow you to select multiple
objects.
A|||Ok,
I was confused by your statement
<coming soon with Service Pack 2, which swaps out the >Summary tab for a new
> context-sensitive tab called Object Explorer Details.
Well, I just wanted to say that on the righ pane (Summary Tab) you can do
that
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in mess
age
news:e0aKhcXDHHA.1196@.TK2MSFTNGP02.phx.gbl...
> (!) I was talking about Object Explorer (the left pane). I never used the
> Summary Tab.
> And as luck would have it, I don't have a pre-SP2 server within reach to
> even see what you're talking about. Again, I was talking about in Object
> Explorer, which I had initially expected to allow you to select multiple
> objects.
> A
>

Generate Script in SQL 2005

In SQL2K, we can generate scripts just for PK and FK, or just Indexes.
Somehow, I could not to do that in SQL 2005, it does not give me the options
to generate only Indexes.
Any idea?
This is a severe shortcoming in the tool (both not being able to right-click
the indexes node under a table and script all, and not being able to select
multiple items anywhere in Object Explorer). But thankfully, there is help
coming soon with Service Pack 2, which swaps out the Summary tab for a new
context-sensitive tab called Object Explorer Details. In this tab, when you
expand a table and highlight the Indexes node on the left, you can select
multiple items on the right, right-click them, and follow a Script > menu.
I talked about this briefly here:
http://www.aaronbertrand.com/rant.asp?r=499
"TBoon" <allblacks15@.hotmail.com> wrote in message
news:uo0a3dODHHA.4404@.TK2MSFTNGP03.phx.gbl...
> In SQL2K, we can generate scripts just for PK and FK, or just Indexes.
> Somehow, I could not to do that in SQL 2005, it does not give me the
> options to generate only Indexes.
> Any idea?
>
|||Hi,Aaron
Hmm, it is possible that I do not understand you , but I can highlight more
than one item (SPfor example) in Object Explorer and script them out to the
new window
I have SQL Server 2005 Dev Edition
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:%23GNKeHPDHHA.3524@.TK2MSFTNGP06.phx.gbl...
> This is a severe shortcoming in the tool (both not being able to
> right-click the indexes node under a table and script all, and not being
> able to select multiple items anywhere in Object Explorer). But
> thankfully, there is help coming soon with Service Pack 2, which swaps out
> the Summary tab for a new context-sensitive tab called Object Explorer
> Details. In this tab, when you expand a table and highlight the Indexes
> node on the left, you can select multiple items on the right, right-click
> them, and follow a Script > menu.
> I talked about this briefly here:
> http://www.aaronbertrand.com/rant.asp?r=499
>
>
>
> "TBoon" <allblacks15@.hotmail.com> wrote in message
> news:uo0a3dODHHA.4404@.TK2MSFTNGP03.phx.gbl...
>
|||I don't know how you could do that. When I click on an object like a table,
and hold shift or control to try and click a second table, the second table
is highlighted (even if I am still holding shift or control).
Maybe you could take a screen shot of what you are talking about, because I
don't know of any node in Object Explorer that allows this (SP2 or prior).
We're talking about Management Studio here, right? Not Query Analyzer?
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23B5w9lSDHHA.3228@.TK2MSFTNGP03.phx.gbl...
> Hi,Aaron
> Hmm, it is possible that I do not understand you , but I can highlight
> more than one item (SPfor example) in Object Explorer and script them out
> to the new window
> I have SQL Server 2005 Dev Edition
|||Hi ,Aaron
> We're talking about Management Studio here, right? Not Query Analyzer?
Sure , here is the morning , but I had already two coffees :-))))))

>I don't know how you could do that. When I click on an object like a
>table, and hold shift or control to try and click a second table, the
>second table is highlighted (even if I am still holding shift or control).
In Summery Tab I click on SP --hold Ctrl button and then secon SP --
I can send you a print screen if you want , just tell me the email address
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:ONxNC3SDHHA.3524@.TK2MSFTNGP06.phx.gbl...
>I don't know how you could do that. When I click on an object like a
>table, and hold shift or control to try and click a second table, the
>second table is highlighted (even if I am still holding shift or control).
> Maybe you could take a screen shot of what you are talking about, because
> I don't know of any node in Object Explorer that allows this (SP2 or
> prior).
> We're talking about Management Studio here, right? Not Query Analyzer?
>
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:%23B5w9lSDHHA.3228@.TK2MSFTNGP03.phx.gbl...
>
|||> In Summery Tab
(!) I was talking about Object Explorer (the left pane). I never used the
Summary Tab.
And as luck would have it, I don't have a pre-SP2 server within reach to
even see what you're talking about. Again, I was talking about in Object
Explorer, which I had initially expected to allow you to select multiple
objects.
A
|||Ok,
I was confused by your statement
<coming soon with Service Pack 2, which swaps out the >Summary tab for a new
> context-sensitive tab called Object Explorer Details.
Well, I just wanted to say that on the righ pane (Summary Tab) you can do
that
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:e0aKhcXDHHA.1196@.TK2MSFTNGP02.phx.gbl...
> (!) I was talking about Object Explorer (the left pane). I never used the
> Summary Tab.
> And as luck would have it, I don't have a pre-SP2 server within reach to
> even see what you're talking about. Again, I was talking about in Object
> Explorer, which I had initially expected to allow you to select multiple
> objects.
> A
>

Sunday, February 19, 2012

Generate a SQL Script to create Indexes

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,
>