Saturday, February 25, 2012

Create linked exchange server

I'm using sql server 2005 and exchange 2003. End result is I want to upload email attachments to a table in sql. No one seems to have any idea how do do this except with .net, which i know nothing about so not really an option for me. I found this bit of info with some extensive web searching. Can anyone help fill in the blanks? I can't get the linked server to work yet.

EXEC sp_addlinkedserver 'exchange',
'Exchange OLE DB provider',
'exoledb.DataSource.1',
'file:\\.\backofficestorage\mailservername\public folders'

Error received:The OLE DB provider "exoledb.DataSource.1" has not been registered.

Does the Exchange Ole DB Driver exist on the SQL Server machine? I am assuming the 2 services are not on the same machine. If not, you may need to install the Exchange SDK or management tools on the SQL Server to get the OleDB driver installed.

Create linked exchange server

I'm using sql server 2005 and exchange 2003. End result is I want to upload email attachments to a table in sql. No one seems to have any idea how do do this except with .net, which i know nothing about so not really an option for me. I found this bit of info with some extensive web searching. Can anyone help fill in the blanks? I can't get the linked server to work yet.

EXEC sp_addlinkedserver 'exchange',
'Exchange OLE DB provider',
'exoledb.DataSource.1',
'file:\\.\backofficestorage\mailservername\public folders'

Error received:The OLE DB provider "exoledb.DataSource.1" has not been registered.

Does the Exchange Ole DB Driver exist on the SQL Server machine? I am assuming the 2 services are not on the same machine. If not, you may need to install the Exchange SDK or management tools on the SQL Server to get the OleDB driver installed.

Create link to dBase?

Hello,
I was wondering what is the best way to link MS SQL server 2000 to dBase IV.
From what I can gather, we should create a linked server and use the MS Jet
4.0 OLE DB provider to connect to Borland's BDE. Then BDE links to the
dBase files.
Is this the correct way? If so, does anyone know where to get a working
version of BDE?
Thanks,
Marc.Using linked server is one of the ways, and I will probably go with that.
But am not sure where to get your BDE drivers...try Googling :-)
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"Marc Thompson" <(NO SPAM) my email address is marc at sycron dot com> wrote
in message news:uuRlYTt%23DHA.3284@.TK2MSFTNGP09.phx.gbl...
Hello,
I was wondering what is the best way to link MS SQL server 2000 to dBase IV.
From what I can gather, we should create a linked server and use the MS Jet
4.0 OLE DB provider to connect to Borland's BDE. Then BDE links to the
dBase files.
Is this the correct way? If so, does anyone know where to get a working
version of BDE?
Thanks,
Marc.|||I have googled for it but haven't found a way to get a copy yet.
I am open to any methods really. I really would prefer not to use BDE.
Thanks,
Marc.
"Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
news:OzhenZt#DHA.2072@.TK2MSFTNGP11.phx.gbl...
> Using linked server is one of the ways, and I will probably go with that.
> But am not sure where to get your BDE drivers...try Googling :-)
> --
> HTH,
> Vyas, MVP (SQL Server)
> http://vyaskn.tripod.com/
> Is .NET important for a database professional?
> http://vyaskn.tripod.com/poll.htm
>
> "Marc Thompson" <(NO SPAM) my email address is marc at sycron dot com>
wrote
> in message news:uuRlYTt%23DHA.3284@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I was wondering what is the best way to link MS SQL server 2000 to dBase
IV.
> From what I can gather, we should create a linked server and use the MS
Jet
> 4.0 OLE DB provider to connect to Borland's BDE. Then BDE links to the
> dBase files.
> Is this the correct way? If so, does anyone know where to get a working
> version of BDE?
> Thanks,
> Marc.
>
>

Create link from the report?

Is it possible create button or link from one report to another report?On Aug 1, 11:26 am, GGill <GG...@.discussions.microsoft.com> wrote:
> Is it possible create button or link from one report to another report?
There are several options available depending on your needs. You can
either use a subreport control that incorporates another report into a
report. Or you can use 'Jump to report' or 'Jump to URL' as part of
the properties (Navigation tab) of a textbox, image, table cell,
matrix cell, etc (via right-clicking the control -> selecting
Properties and selecting the Navigation tab). Hope this helps.
Regards,
Enrique Martinez
Sr. Software Consultant|||IT WORKED.
THANK YOU SO MUCH.
"EMartinez" wrote:
> On Aug 1, 11:26 am, GGill <GG...@.discussions.microsoft.com> wrote:
> > Is it possible create button or link from one report to another report?
>
> There are several options available depending on your needs. You can
> either use a subreport control that incorporates another report into a
> report. Or you can use 'Jump to report' or 'Jump to URL' as part of
> the properties (Navigation tab) of a textbox, image, table cell,
> matrix cell, etc (via right-clicking the control -> selecting
> Properties and selecting the Navigation tab). Hope this helps.
> Regards,
> Enrique Martinez
> Sr. Software Consultant
>|||You're welcome. Glad I could help.
Regards,
Enrique Martinez
Sr. Software Consultant
GGill wrote:
> IT WORKED.
> THANK YOU SO MUCH.
>
> "EMartinez" wrote:
> > On Aug 1, 11:26 am, GGill <GG...@.discussions.microsoft.com> wrote:
> > > Is it possible create button or link from one report to another report?
> >
> >
> > There are several options available depending on your needs. You can
> > either use a subreport control that incorporates another report into a
> > report. Or you can use 'Jump to report' or 'Jump to URL' as part of
> > the properties (Navigation tab) of a textbox, image, table cell,
> > matrix cell, etc (via right-clicking the control -> selecting
> > Properties and selecting the Navigation tab). Hope this helps.
> >
> > Regards,
> >
> > Enrique Martinez
> > Sr. Software Consultant
> >
> >

Create Link from SQL 2000 to AS400

Hi
I have found an
issue when I try to view or access the tables on the AS400 from my client machine. I receive the following error when I make that attempt:

Error 7399: OLE DB Provider 'MSDASQL' reported an error.
Data Source Name not found and no default driver specified.

Any help anyone can give me on this issue would be greatly appreciated

Thanks
PhilHi,

Could you be more specific?

You need to create link from SQL 2000 to AS400 but which is the AS400 database?
You have installed the adequate driver?

My apologies for my english. I currently write in portuguese.

Regards,

Dlson Castro.
delson_castro@.ig.com.br

Originally posted by pholtquist
Hi
I have found an
issue when I try to view or access the tables on the AS400 from my client machine. I receive the following error when I make that attempt:

Error 7399: OLE DB Provider 'MSDASQL' reported an error.
Data Source Name not found and no default driver specified.

Any help anyone can give me on this issue would be greatly appreciated

Thanks
Phil|||It sounds like the error is from the linked server defined incorrectly on SQL Server.

You say yhou are accessing the tables from your client machine. If the SQL Server is on a different machine, remember that you need to set up the ODBC DSN (or the 'DB2OLEDB' driver) on the server, not your client.

See sp_addlinkedserver in BOL for a description of what is needed.

Please provide more information if this does not help or is unclear.

HueyStLoui

Originally posted by pholtquist
Hi
I have found an
issue when I try to view or access the tables on the AS400 from my client machine. I receive the following error when I make that attempt:

Error 7399: OLE DB Provider 'MSDASQL' reported an error.
Data Source Name not found and no default driver specified.

Any help anyone can give me on this issue would be greatly appreciated

Thanks
Phil

create linefeed in field

Hello,

I would like to create more lines by concatenating values.
When I use: <select 'This' + ' ' + 'is' + ' ' + 'an' + ' ' +
'example'> the result is <This is an example> (on the same line).
I woul like to get:
<This
is
an
example> (each 'word' on a new line, but in 1 field)
Whis SQL statement do i have to use?"Hans" <hans.de.korte@.prominent.nl> wrote in message
news:ae7dcba4.0402200557.1942ab24@.posting.google.c om...
> Hello,
> I would like to create more lines by concatenating values.
> When I use: <select 'This' + ' ' + 'is' + ' ' + 'an' + ' ' +
> 'example'> the result is <This is an example> (on the same line).
> I woul like to get:
> <This
> is
> an
> example> (each 'word' on a new line, but in 1 field)
> Whis SQL statement do i have to use?

See CHAR() in Books Online.

Simon|||It looks like you are trying to format a string in SQL. It is always a
good practice to do this kind of formatting in the application. Given
that in order to add a line break as part of the string you need to
use the char function. char(13)+char(10) make a line break i.e. line
feed and carriage return. To answer your example you can try
declare @.cf varchar(2)
set @.cf=' '+char(13)+char(10)+' '
select 'This' + @.cr + 'is' + @.cf + 'an' + @.cf + 'example'

If you don't want to use the variable then you substitute the variable
with the expression ' '+char(13)+char(10)+' '. As I mentioned before
it is not a best practice to do this kind of formatting at database
level.

Ramesh

hans.de.korte@.prominent.nl (Hans) wrote in message news:<ae7dcba4.0402200557.1942ab24@.posting.google.com>...
> Hello,
> I would like to create more lines by concatenating values.
> When I use: <select 'This' + ' ' + 'is' + ' ' + 'an' + ' ' +
> 'example'> the result is <This is an example> (on the same line).
> I woul like to get:
> <This
> is
> an
> example> (each 'word' on a new line, but in 1 field)
> Whis SQL statement do i have to use?

create linefeed in field

Hello,
I would like to create more lines by concatenating values.
When I use: <select 'This' + ' ' + 'is' + ' ' + 'an' + ' ' + 'example'> the result is <This is an example> (on the same line).
I woul like to get:
<This
is
an
example> (each 'word' on a new line, but in 1 field)
Whis SQL statement do i have to use?SELECT 'This' + ' ' + CHAR(10) + 'is' + CHAR(10) + ' ' + 'an' + CHAR(10) + '
' + 'example'
--
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
"Hans de Korte" <hans.de.korte@.prominent.nl> wrote in message
news:06D0883E-6C6A-48F5-8205-58FA1B716BDF@.microsoft.com...
> Hello,
> I would like to create more lines by concatenating values.
> When I use: <select 'This' + ' ' + 'is' + ' ' + 'an' + ' ' + 'example'>
the result is <This is an example> (on the same line).
> I woul like to get:
> <This
> is
> an
> example> (each 'word' on a new line, but in 1 field)
> Whis SQL statement do i have to use?|||You can use carriage return (CHAR(13)) and line feed (CHAR(10)) separators:
DECLARE @.CrLF AS char(2)
SET @.CrLF = CHAR(13) + CHAR(13)
SELECT 'This' + @.CrLF +
'is' + @.CrLF +
'an' + @.CrLF +
'example'
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Hans de Korte" <hans.de.korte@.prominent.nl> wrote in message
news:06D0883E-6C6A-48F5-8205-58FA1B716BDF@.microsoft.com...
> Hello,
> I would like to create more lines by concatenating values.
> When I use: <select 'This' + ' ' + 'is' + ' ' + 'an' + ' ' + 'example'>
the result is <This is an example> (on the same line).
> I woul like to get:
> <This
> is
> an
> example> (each 'word' on a new line, but in 1 field)
> Whis SQL statement do i have to use?|||Thanks, I will try
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

create linefeed in field

Hello,
I would like to create more lines by concatenating values.
When I use: <select 'This' + ' ' + 'is' + ' ' + 'an' + ' ' + 'example'> the
result is <This is an example> (on the same line).
I woul like to get:
<This
is
an
example> (each 'word' on a new line, but in 1 field)
Whis SQL statement do i have to use?SELECT 'This' + ' ' + CHAR(10) + 'is' + CHAR(10) + ' ' + 'an' + CHAR(10) + '
' + 'example'
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
"Hans de Korte" <hans.de.korte@.prominent.nl> wrote in message
news:06D0883E-6C6A-48F5-8205-58FA1B716BDF@.microsoft.com...
> Hello,
> I would like to create more lines by concatenating values.
> When I use: <select 'This' + ' ' + 'is' + ' ' + 'an' + ' ' + 'example'>
the result is <This is an example> (on the same line).
> I woul like to get:
> <This
> is
> an
> example> (each 'word' on a new line, but in 1 field)
> Whis SQL statement do i have to use?|||You can use carriage return (CHAR(13)) and line feed (CHAR(10)) separators:
DECLARE @.CrLF AS char(2)
SET @.CrLF = CHAR(13) + CHAR(13)
SELECT 'This' + @.CrLF +
'is' + @.CrLF +
'an' + @.CrLF +
'example'
Hope this helps.
Dan Guzman
SQL Server MVP
"Hans de Korte" <hans.de.korte@.prominent.nl> wrote in message
news:06D0883E-6C6A-48F5-8205-58FA1B716BDF@.microsoft.com...
> Hello,
> I would like to create more lines by concatenating values.
> When I use: <select 'This' + ' ' + 'is' + ' ' + 'an' + ' ' + 'example'>
the result is <This is an example> (on the same line).
> I woul like to get:
> <This
> is
> an
> example> (each 'word' on a new line, but in 1 field)
> Whis SQL statement do i have to use?|||Thanks, I will try
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!

Create Job From Package

Trying to re-create a job after creating a new package. Old job was called
with the following synax:
DTSRun
/~Z0x322A50F270D63181ED3C87B10CDFB82666EFD66DAA4A08 5A03A8BC5BE88F8ED29DDEA7B407C5035D24F856D65611E761 9014C84B379DD1CCDEDB18D65E657D60798D4F56B37D443D16 CE7A685E612C69DA8A82131E8A281EED2D73345D8E942D9BAE 8B20CB8A6844A569E61F23A0079738A695D8847C6811CFF198 6E161BE2D3A581BE388FDF14D4703D00
Where is this number located? Can this package be called using the syntax:
DTSRUN /N 'Name of my Package'
?
Regards,
Jamie
As my reply previously...
the easiest thing to do is to use DTSRUNUI to generate human-readable
command-line arguments and enter these in your DTS scheduled jobs, provided
they don't include passwords ie overwrite these arguments. The command you
have is encrypted and I don't know of any way to have it unencrypted. If
your question is how to relate this job to the parent DTS package, then the
name of the job should be the same as the package name.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .
|||Is this done to hide the sa password? I'm not sure why it would have been
encrypted. Must the permissions all coincide with the agent user-login if
those permissions are not run as sa? What might happen if the previous dba's
role/permissions on the database are no longer "systemadmin" and the job runs
under the context of their login?
Regards,
Jamie
"Paul Ibison" wrote:

> As my reply previously...
> the easiest thing to do is to use DTSRUNUI to generate human-readable
> command-line arguments and enter these in your DTS scheduled jobs, provided
> they don't include passwords ie overwrite these arguments. The command you
> have is encrypted and I don't know of any way to have it unencrypted. If
> your question is how to relate this job to the parent DTS package, then the
> name of the job should be the same as the package name.
> Cheers,
> Paul Ibison SQL Server MVP, www.replicationanswers.com .
>
>
|||Jamie,
encrypting passwords is one reason it's useful - I certainly wouldn't want
my sa password in plain text hanging around
I generally prefer trusted security anyway for these packages. If not,
you'll have a sysadmin password available or have to encrypt the whole line
(or set up a proxy). The ideal solution for myself is to be able to read the
command line in the job to see what it is doing, and not have a security
worry, so trusted security fits the bill.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .

Create Instance of Notification Service

Hi,

I am getting the following error.

Event ID:XmlValidationError Source:NSEventStrings

while creating Instance of Notification Service.

Hi,

This is probably becuase your instance definition file or application definition file is not compatible with SQL NS schemas.

Following link contains complete template of instance and application definition file. Make sure your xml adheres to it.

http://msdn2.microsoft.com/en-us/library/ms145917.aspx
http://msdn2.microsoft.com/en-US/library/ms145313.aspx


Shamir

|||As Shamir mentioned, both the ICF and ADF must be well-formed and valid XML documents. They are validated against an XSD schema in your SSNS installation folder.

Keep in mind that XML is case-sensitive.

HTH...

Joe

Create Instance of Notification Service

Hi,

I am getting the following error.

Event ID:

XmlValidationError

Source:

NSEventStrings

while creating Instance of Notification Service.

Hi,

This is probably becuase your instance definition file or application definition file is not compatible with SQL NS schemas.

Following link contains complete template of instance and application definition file. Make sure your xml adheres to it.

http://msdn2.microsoft.com/en-us/library/ms145917.aspx
http://msdn2.microsoft.com/en-US/library/ms145313.aspx


Shamir|||As Shamir mentioned, both the ICF and ADF must be well-formed and valid XML documents. They are validated against an XSD schema in your SSNS installation folder.

Keep in mind that XML is case-sensitive.

HTH...

Joe

Create Instance of Notification Service

Hi,

I am getting the following error.

Event ID:XmlValidationError Source:NSEventStrings

while creating Instance of Notification Service.

Hi,

This is probably becuase your instance definition file or application definition file is not compatible with SQL NS schemas.

Following link contains complete template of instance and application definition file. Make sure your xml adheres to it.

http://msdn2.microsoft.com/en-us/library/ms145917.aspx
http://msdn2.microsoft.com/en-US/library/ms145313.aspx


Shamir

|||As Shamir mentioned, both the ICF and ADF must be well-formed and valid XML documents. They are validated against an XSD schema in your SSNS installation folder.

Keep in mind that XML is case-sensitive.

HTH...

Joe

Create Instance

How do I create my first instance for an MSDE database?To install a default instance, type in the following command at the dos
prompt. It also requires an strong password for sa account.
setup SAPWD=<someStrongPassword>
For a named instance, you will need to type in the following command at the
dos command prompt.
setup INSTANCENAME=<instance name you input> SECURITYMODE=SQL
SAPWD=<someStrongPassword>
- Mac
"Arne" <arnenospam@.garvander.com> wrote in message
news:01b401c35d07$1dcdd9d0$a301280a@.phx.gbl...
> How do I create my first instance for an MSDE database?

Create indexes for Query Optimization

I am using ASP.net application on SQL server 2005.
I am getting data from the DB using this SQL statement from 2 tables:
Select Table1.a,Table1.b,Table2.C from Table1 INNER JOIN Table1 ON
Table2.e=Table.e Where Table1.a=XXX AND Table1.b>YYY Order Table1.a DESC
Table1 has around 2,000,000 Records and table has 3 records.
The query is running very slow.
How do Optimize the query using Indexes ?
On Which fields should I create the indexes ?
Thanks
ra294
ra294@.hotmail.com
On Jan 7, 6:56Xpm, "ra294" <ra...@.hotmail.com> wrote:
> I am using ASP.net application on SQL server 2005.
> I am getting data from the DB using this SQL statement from 2 tables:
> Select Table1.a,Table1.b,Table2.C from Table1 INNER JOIN Table1 ON
> Table2.e=Table.e Where Table1.a=XXX AND Table1.b>YYY Order Table1.a DESC
> Table1 has around 2,000,000 Records and table has 3 records.
> The query is running very slow.
> How do Optimize the query using Indexes ?
> On Which fields should I create the indexes X?
> Thanks
> ra294
> ra...@.hotmail.com
Do you have index on either columns a or b? Also, you might consider
remove the order by clause and do it later.

Create indexes for Query Optimization

I am using ASP.net application on SQL server 2005.
I am getting data from the DB using this SQL statement from 2 tables:
Select Table1.a,Table1.b,Table2.C from Table1 INNER JOIN Table1 ON
Table2.e=Table.e Where Table1.a=XXX AND Table1.b>YYY Order Table1.a DESC
Table1 has around 2,000,000 Records and table has 3 records.
The query is running very slow.
How do Optimize the query using Indexes ?
On Which fields should I create the indexes ?
Thanks
ra294
ra294@.hotmail.comra294 wrote:
> I am using ASP.net application on SQL server 2005.
> I am getting data from the DB using this SQL statement from 2 tables:
> Select Table1.a,Table1.b,Table2.C from Table1 INNER JOIN Table1 ON
> Table2.e=Table.e Where Table1.a=XXX AND Table1.b>YYY Order Table1.a DESC
> Table1 has around 2,000,000 Records and table has 3 records.
> The query is running very slow.
> How do Optimize the query using Indexes ?
> On Which fields should I create the indexes ?
> Thanks
> ra294
> ra294@.hotmail.com
>
>
try using database engine tuning advisor, find it in tools menu of the
management studio|||Without looking at the data Im just guessing but try doing this:
Table1 index: Key columns: a,b,e
Table2 index: key columns: e included: c
MC
"ra294" <ra294@.hotmail.com> wrote in message
news:uTLstxSUIHA.5404@.TK2MSFTNGP03.phx.gbl...
>I am using ASP.net application on SQL server 2005.
> I am getting data from the DB using this SQL statement from 2 tables:
> Select Table1.a,Table1.b,Table2.C from Table1 INNER JOIN Table1 ON
> Table2.e=Table.e Where Table1.a=XXX AND Table1.b>YYY Order Table1.a DESC
> Table1 has around 2,000,000 Records and table has 3 records.
> The query is running very slow.
> How do Optimize the query using Indexes ?
> On Which fields should I create the indexes ?
> Thanks
> ra294
> ra294@.hotmail.com
>
>|||ra294,
You might want to recheck your posting. The query is not valid (because
of typos?), and the number of rows are suspect (really just 3 rows in
one table and 2 million rows in the other table?).
How many rows does the query return? 3? 6 million? How big is the table
with the 2 million rows (how many pages or how much MB)?
How slow is the query currently? 200 milliseconds, 5 seconds, 5 minutes?
In general, you should always define a Primary Key for each table. This
will automatically create a corresponding unique index. You should also
define any Foreign Key relations. In general, it is a good idea to index
Foreign Key relations.
If you would like more assistence, then please post simplified DDL (and
the answers to the questions above).
--
Gert-jan
ra294 wrote:
> I am using ASP.net application on SQL server 2005.
> I am getting data from the DB using this SQL statement from 2 tables:
> Select Table1.a,Table1.b,Table2.C from Table1 INNER JOIN Table1 ON
> Table2.e=Table.e Where Table1.a=XXX AND Table1.b>YYY Order Table1.a DESC
> Table1 has around 2,000,000 Records and table has 3 records.
> The query is running very slow.
> How do Optimize the query using Indexes ?
> On Which fields should I create the indexes ?
> Thanks
> ra294
> ra294@.hotmail.com|||On Jan 7, 6:56=A0pm, "ra294" <ra...@.hotmail.com> wrote:
> I am using ASP.net application on SQL server 2005.
> I am getting data from the DB using this SQL statement from 2 tables:
> Select Table1.a,Table1.b,Table2.C from Table1 INNER JOIN Table1 ON
> Table2.e=3DTable.e Where Table1.a=3DXXX AND Table1.b>YYY Order Table1.a DE=SC
> Table1 has around 2,000,000 Records and table has 3 records.
> The query is running very slow.
> How do Optimize the query using Indexes ?
> On Which fields should I create the indexes =A0?
> Thanks
> ra294
> ra...@.hotmail.com
Do you have index on either columns a or b? Also, you might consider
remove the order by clause and do it later.

Create Indexes & extra columns!

Hi guys
2 questions.
Is it recomenable to create
1. Indexes
2. extra columns
on a table while the database is being used?
I have not yet had the guts to do it while the database was in use however
it would be somewhat easier if I could?
Regards
Jonas
Jonas Larsen wrote:
> Hi guys
> 2 questions.
> Is it recomenable to create
> 1. Indexes
> 2. extra columns
> on a table while the database is being used?
> I have not yet had the guts to do it while the database was in use
> however it would be somewhat easier if I could?
> Regards
> Jonas
Recommended is a loaded word. You can certainly perform both operations
while users are accessing the database. Adding a column should be quick
as long as you don't have to load data into the new column. Adding an
index is a more time consuming process if the table is large. If you
create a clustered index, you'll likely take the table offline until the
operation is complete and all non-clustered indexes are rebuilt.
If you are concerned about affecting the availability of the table in
question, schedule the operation to take place at night using the SQL
Server Agent.
David G.
|||I agree with David, if you choose to do this during the day, the structures
will still ( automatically) be unavailable until the process completes,
(which could take some time.)
most people would schedule this during off hours... and backup prior...
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Jonas Larsen" <Jonas.Larsen@.Alcan.com> wrote in message
news:%23m%23Ai4liEHA.3288@.TK2MSFTNGP10.phx.gbl...
> Hi guys
> 2 questions.
> Is it recomenable to create
> 1. Indexes
> 2. extra columns
> on a table while the database is being used?
> I have not yet had the guts to do it while the database was in use however
> it would be somewhat easier if I could?
> Regards
> Jonas
>

Create Indexes & extra columns!

Hi guys
2 questions.
Is it recomenable to create
1. Indexes
2. extra columns
on a table while the database is being used?
I have not yet had the guts to do it while the database was in use however
it would be somewhat easier if I could?
Regards
JonasJonas Larsen wrote:
> Hi guys
> 2 questions.
> Is it recomenable to create
> 1. Indexes
> 2. extra columns
> on a table while the database is being used?
> I have not yet had the guts to do it while the database was in use
> however it would be somewhat easier if I could?
> Regards
> Jonas
Recommended is a loaded word. You can certainly perform both operations
while users are accessing the database. Adding a column should be quick
as long as you don't have to load data into the new column. Adding an
index is a more time consuming process if the table is large. If you
create a clustered index, you'll likely take the table offline until the
operation is complete and all non-clustered indexes are rebuilt.
If you are concerned about affecting the availability of the table in
question, schedule the operation to take place at night using the SQL
Server Agent.
David G.|||I agree with David, if you choose to do this during the day, the structures
will still ( automatically) be unavailable until the process completes,
(which could take some time.)
most people would schedule this during off hours... and backup prior...
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Jonas Larsen" <Jonas.Larsen@.Alcan.com> wrote in message
news:%23m%23Ai4liEHA.3288@.TK2MSFTNGP10.phx.gbl...
> Hi guys
> 2 questions.
> Is it recomenable to create
> 1. Indexes
> 2. extra columns
> on a table while the database is being used?
> I have not yet had the guts to do it while the database was in use however
> it would be somewhat easier if I could?
> Regards
> Jonas
>

Create Indexes & extra columns!

Hi guys
2 questions.
Is it recomenable to create
1. Indexes
2. extra columns
on a table while the database is being used?
I have not yet had the guts to do it while the database was in use however
it would be somewhat easier if I could?
Regards
JonasJonas Larsen wrote:
> Hi guys
> 2 questions.
> Is it recomenable to create
> 1. Indexes
> 2. extra columns
> on a table while the database is being used?
> I have not yet had the guts to do it while the database was in use
> however it would be somewhat easier if I could?
> Regards
> Jonas
Recommended is a loaded word. You can certainly perform both operations
while users are accessing the database. Adding a column should be quick
as long as you don't have to load data into the new column. Adding an
index is a more time consuming process if the table is large. If you
create a clustered index, you'll likely take the table offline until the
operation is complete and all non-clustered indexes are rebuilt.
If you are concerned about affecting the availability of the table in
question, schedule the operation to take place at night using the SQL
Server Agent.
David G.|||I agree with David, if you choose to do this during the day, the structures
will still ( automatically) be unavailable until the process completes,
(which could take some time.)
most people would schedule this during off hours... and backup prior...
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Jonas Larsen" <Jonas.Larsen@.Alcan.com> wrote in message
news:%23m%23Ai4liEHA.3288@.TK2MSFTNGP10.phx.gbl...
> Hi guys
> 2 questions.
> Is it recomenable to create
> 1. Indexes
> 2. extra columns
> on a table while the database is being used?
> I have not yet had the guts to do it while the database was in use however
> it would be somewhat easier if I could?
> Regards
> Jonas
>

Create indexes - own File Group

With help of others on this group, I've been learning and researching
about indexes; an area I neglected.
I see I can specify which filegroup I wish to create an index, which
the default is Primary.
I have more than one drive in my SQL server where I put data and logs
on their own logical raid groups.
My databases are SIMPLE, so they dont use much, if any logs (none as I
understand).
I was thinking of adding an additional file to my database and use it
solely for the indexes.
Any thoughts?

SQL Server 2005 Enterprise x64 SP2
8 disk SAS Raid 1+0 w/ 512mb ram w/ battery backup.
Thanks,
Rob
"rcamarda" <robert.a.camarda@.gmail.comwrote in message
news:1173725223.934126.197140@.30g2000cwc.googlegro ups.com...

Quote:

Originally Posted by

With help of others on this group, I've been learning and researching
about indexes; an area I neglected.
I see I can specify which filegroup I wish to create an index, which
the default is Primary.
I have more than one drive in my SQL server where I put data and logs
on their own logical raid groups.
My databases are SIMPLE, so they dont use much, if any logs (none as I
understand).
I was thinking of adding an additional file to my database and use it
solely for the indexes.
Any thoughts?
>


Yes, I've done this and putting your non-clustered indexes in its own group
can provide an improvement. Especially for rebuilds and the like.

HOWEVER, your database most definitely DOES use the logs. SIMPLE simply
means that as soon as transactions are complete, the log is truncated so it
won't grow. But it is definitely being used.

Keep in mind that w/o logs, you seriously hamper your disaster recovery
options. Since you're running SQL Server Enterprise, that makes me suspect
this is more than just a little test site.

Quote:

Originally Posted by

SQL Server 2005 Enterprise x64 SP2
8 disk SAS Raid 1+0 w/ 512mb ram w/ battery backup.
Thanks,
Rob
>


--
Greg Moore
SQL Server DBA Consulting
Email: sql (at) greenms.com http://www.greenms.com|||Greg,
Its a data warehouse. I have tools that could rebuild an empty
database pretty quickly (few hours) and I have daily backups. Builds
take about 2 hours, then its read only the rest of the day.
I use enterprise because of our licensing.

Thanks for the info!

Quote:

Originally Posted by

>
Yes, I've done this and putting your non-clustered indexes in its own group
can provide an improvement. Especially for rebuilds and the like.
>
HOWEVER, your database most definitely DOES use the logs. SIMPLE simply
means that as soon as transactions are complete, the log is truncated so it
won't grow. But it is definitely being used.
>
Keep in mind that w/o logs, you seriously hamper your disaster recovery
options. Since you're running SQL Server Enterprise, that makes me suspect
this is more than just a little test site.
>

Quote:

Originally Posted by

SQL Server 2005 Enterprise x64 SP2
8 disk SAS Raid 1+0 w/ 512mb ram w/ battery backup.
Thanks,
Rob


>
--
Greg Moore
SQL Server DBA Consulting
Email: sql (at) greenms.com http://www.greenms.com

Create Index....Help

Ok,
I create my view like this (for now is exactly what I need):
USE tsNess2
GO
SET NUMERIC_ROUNDABORT OFF
GO
SET
ANSI_PADDING,ANSI_WARNINGS,CONCAT_NULL_Y
IELDS_NULL,ARITHABORT,QUOTED_IDENTIF
IER,ANSI_NULLS
ON
GO
CREATE VIEW V1
WITH SCHEMABINDING
AS
SELECT t1.MemberId, t1.PeriodID, t8.start_date, t6.amount_type_id,
t6.amount_type,
SUM(CASE WHEN t2.amountTypeId = 7 THEN t2.amount
WHEN t2.amountTypeId = 23 THEN - t2.amount END) AS Purchase,
SUM(CASE WHEN t2.amountTypeId = 8 THEN t2.amount
WHEN t2.amountTypeId = 24 THEN - t2.amount END) AS Matrix,
SUM(CASE WHEN t2.amountTypeId = 20 THEN t2.amount
WHEN t2.amountTypeId = 21 THEN - t2.amount END) AS QualiFly,
SUM(CASE WHEN t2.amountTypeId = 9 THEN t2.amount
WHEN t2.amountTypeId = 25 THEN - t2.amount END) AS Dist,
SUM(CASE WHEN t2.amountTypeId = 10 THEN t2.amount
WHEN t2.amountTypeId = 26 THEN - t2.amount END) AS SM,
SUM(CASE WHEN t2.amountTypeId = 11 THEN t2.amount
WHEN t2.amountTypeId = 27 THEN - t2.amount END) AS BreakAway,
SUM(CASE WHEN t2.amountTypeId = 13 THEN t2.amount
WHEN t2.amountTypeId = 14 THEN - t2.amount END) AS Transfer,
SUM(CASE WHEN t2.amountTypeId = 28 THEN t2.amount
WHEN t2.amountTypeId = 15 THEN - t2.amount END) AS Spent
FROM dbo.tblTravelDetail t1 INNER JOIN
dbo.tblTravelDetailAmount t2 ON t1.TravelDetailId
= t2.TravelDetailId INNER JOIN
dbo.tblTravelDetailMember t4 ON t1.TravelDetailId
= t4.TravelDetailId INNER JOIN
dbo.tblTravelEvent t5 ON t1.TravelEventId =
t5.TravelEventId INNER JOIN
dbo.amount_type t6 ON t2.amountTypeId =
t6.amount_type_id INNER JOIN
dbo.period t8 ON t1.PeriodID = t8.period_id
WHERE (t1.MemberId = '222') AND (t2.amount <> 0)
GROUP BY t1.MemberId, t1.PeriodID, t8.start_date, t6.amount_type_id,
t6.amount_type
GO
but then when I do this:
CREATE UNIQUE CLUSTERED INDEX IV1 ON V1 (MemberId)
GO
I get "Server: Msg 8662, Level 16, State 1, Line 1
An index cannot be created on the view 'V1' because the view definition
includes an unknown value (the sum of a nullable expression)."
And cannot create my index.
Any help is appreciated.
Thanks,
TrintHello, Trint
Try to change the expressions to something like:
SUM(CASE WHEN ... THEN ... ELSE 0 END)
so the result would not be NULL-able.
Razvan|||Razvan,
Ok, that worked in getting me past that one error...BUT now I get this
error:
"An index cannot be created on the view 'V1' because the view
definition does not include count_big(*)."
Thanks,
Trint|||When the view's query is an aggregate query, it must also include the
COUNT_BIG(*) aggregate function. It's the same function as COUNT(*) only the
output returned is a BIGINT as opposed to INT. SQL Server can maintain the
index more efficiently when the count of rows in the group is known. Anyway,
that's not an option rather a requirement. Before you get any further
errors, please review the section on Indexed Views in Books Online. It's all
described there.
Cheers,
--
BG, SQL Server MVP
www.SolidQualityLearning.com
"trint" <trinity.smith@.gmail.com> wrote in message
news:1123517679.229061.256120@.g44g2000cwa.googlegroups.com...
> Razvan,
> Ok, that worked in getting me past that one error...BUT now I get this
> error:
> "An index cannot be created on the view 'V1' because the view
> definition does not include count_big(*)."
> Thanks,
> Trint
>|||Ok, thanks...But now, I'm getting this error after adding the
COUNT_BIG(*) aggregate function :
Server: Msg 1505, Level 16, State 1, Line 1
CREATE UNIQUE INDEX terminated because a duplicate key was found for
index ID 1. Most significant primary key is '102'.
The statement has been terminated.
Thanks,
Trint|||This is basic sql - your query is attempting to generate sums based on
amout_type_id, yet that column is also included in the group by clause
(meaning your attempt to sum by case expressions is pointless). And as the
message says, you have duplicates - which should be expected based on the
query.|||try adding a field(that introduces uniqueness) to your index so that it
removes the duplicates.(say periodid -- if you have one then add it as the
last key)
this should solve your problem..
Pradeep Kutty
"trint" <trinity.smith@.gmail.com> wrote in message
news:1123519812.442179.233120@.g14g2000cwa.googlegroups.com...
> Ok, thanks...But now, I'm getting this error after adding the
> COUNT_BIG(*) aggregate function :
> Server: Msg 1505, Level 16, State 1, Line 1
> CREATE UNIQUE INDEX terminated because a duplicate key was found for
> index ID 1. Most significant primary key is '102'.
> The statement has been terminated.
> Thanks,
> Trint
>|||Pradeep,
I give up on this one index...HOWEVER, the view that I created is the
solution to my speed problem. It returns the rows in around 2 to 4
seconds on a query for Reporting Services.
Thanks,
Trint
Pradeep Kutty wrote:
> try adding a field(that introduces uniqueness) to your index so that it
> removes the duplicates.(say periodid -- if you have one then add it as the
> last key)
> this should solve your problem..
> Pradeep Kutty
> "trint" <trinity.smith@.gmail.com> wrote in message
> news:1123519812.442179.233120@.g14g2000cwa.googlegroups.com...

Create INDEX within CREATE TABLE DDL

Hi

Minor and inconsequential but sometimes you just gotta know:

Is it possible to define a non-primary key index within a Create Table statement? I can create a constraint and a PK. I can create the table and then add the index. I just wondered if you can do it in one statement.

e.g. I have:

CREATE TABLE MyT
(MyT_ID INT Identity(1, 1) CONSTRAINT MyT_PK PRIMARY KEY Clustered,
MyT_Desc Char(40) NOT NULL CONSTRAINT MyT_idx1 UNIQUE NONCLUSTERED ON [DEFAULT])
which creates a table with a PK and unique constraint.
I would like (pseudo SQL):
CREATE TABLE MyT
(MyT_ID INT Identity(1, 1) CONSTRAINT MyT_PK PRIMARY KEY Clustered,
MyT_Desc Char(40) NOT NULL CONSTRAINT MyT_idx1 UNIQUE INDEX NONCLUSTERED ON [DEFAULT])

No big deal - just curious :D Once I know I can stop scouring BOL for clues.

Tks in advanceI don't think so. I don't recall seeing any syntax that allows this. Non-clustered indexes are separate objects from the table, and that is probably why they need to be created separately, and can be dropped separately as well.|||I don't think so. I don't recall seeing any syntax that allows this. Non-clustered indexes are separate objects from the table, and that is probably why they need to be created separately, and can be dropped separately as well.
Cheers BM - didn't think of it like that - that does kind of make sense - you can't create an object dependent on another object before the first object exists. Or something similar but more felicitous ;)

Create INDEX WITH DROP_EXISTING

Hello,
Can I create an index ( which is not clustered) with DROP_EXISTING ON ?
Shall I still use on [PRIMARY]?
Create INDEX [name] ON [table name] ([column])
WITH DROP_EXISTING ON [PRIMARY]
Thank you,
Y
:rolleyes:clustered or not, you can use this.

Primary refers to the filegroup you would like to physically create the index on and it is an optional part of the create index statement.|||Thank you so much

create index with drop existing

Create index with drop existing after succesfull creation,
when dbcc checktable is run, at times it does not finish
at all, when killed and again submitted runs okay.
Vinodh,
Are you saying that the dbcc does not finish or the create index? How long
did you wait? How big is the table, and how many indexes on there?
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
"Vinodh" <anonymous@.discussions.microsoft.com> wrote in message
news:b85901c437d6$ef3b81c0$a401280a@.phx.gbl...
> Create index with drop existing after succesfull creation,
> when dbcc checktable is run, at times it does not finish
> at all, when killed and again submitted runs okay.
>

create index with drop existing

Create index with drop existing after succesfull creation,
when dbcc checktable is run, at times it does not finish
at all, when killed and again submitted runs okay.Vinodh,
Are you saying that the dbcc does not finish or the create index? How long
did you wait? How big is the table, and how many indexes on there?
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
"Vinodh" <anonymous@.discussions.microsoft.com> wrote in message
news:b85901c437d6$ef3b81c0$a401280a@.phx.gbl...
> Create index with drop existing after succesfull creation,
> when dbcc checktable is run, at times it does not finish
> at all, when killed and again submitted runs okay.
>

create index with drop existing

Create index with drop existing after succesfull creation,
when dbcc checktable is run, at times it does not finish
at all, when killed and again submitted runs okay.Vinodh,
Are you saying that the dbcc does not finish or the create index? How long
did you wait? How big is the table, and how many indexes on there?
--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
"Vinodh" <anonymous@.discussions.microsoft.com> wrote in message
news:b85901c437d6$ef3b81c0$a401280a@.phx.gbl...
> Create index with drop existing after succesfull creation,
> when dbcc checktable is run, at times it does not finish
> at all, when killed and again submitted runs okay.
>

'CREATE INDEX' Statement...Faster?

I am indexing a 32 millon row table with a unqine clustered index and
the run time for the create index statement is over 4 hours long. This
runs is too slow and may cost me a job If i cant find a faster way to
create index on large table.
Can anyone help.
Hi
What is the version of SQL Server?
<GreenHillCourt@.gmail.com> wrote in message
news:a7661fdd-12e9-4a12-969f-6ec961eab992@.n1g2000prb.googlegroups.com...
>I am indexing a 32 millon row table with a unqine clustered index and
> the run time for the create index statement is over 4 hours long. This
> runs is too slow and may cost me a job If i cant find a faster way to
> create index on large table.
> Can anyone help.
|||i don't think it would be faster. Clustered Index is the way data is stored
physically in the hard disk.
bye!
"GreenHillCourt@.gmail.com" wrote:

> I am indexing a 32 millon row table with a unqine clustered index and
> the run time for the create index statement is over 4 hours long. This
> runs is too slow and may cost me a job If i cant find a faster way to
> create index on large table.
> Can anyone help.
>
|||Setting the database to simple recovery should improve compared to full recovery. At least it will
cut down on the logging. But the data shuffling still has to occur of course...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"DarthSidious" <DarthSidious@.discussions.microsoft.com> wrote in message
news:15C6F565-D67E-4912-8424-BFBDF0EC88A2@.microsoft.com...[vbcol=seagreen]
>i don't think it would be faster. Clustered Index is the way data is stored
> physically in the hard disk.
> bye!
> "GreenHillCourt@.gmail.com" wrote:
|||<GreenHillCourt@.gmail.com> wrote in message
news:a7661fdd-12e9-4a12-969f-6ec961eab992@.n1g2000prb.googlegroups.com...
>I am indexing a 32 millon row table with a unqine clustered index and
> the run time for the create index statement is over 4 hours long. This
> runs is too slow and may cost me a job If i cant find a faster way to
> create index on large table.
As others have said, if you're creating the clustered index, not much you
can do other than perhaps look at a faster disk subsystem (say raid 10 vs
RAID 5, etc.)
If you mean you're creating a non-clustered index on a table that has an
existing clustered index, one thing that can certainly help is putting the
non-clustered index on its own set of disks.

> Can anyone help.
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html
|||Have you tried creating the index without clustering? If I'm not mistaken,
it should then not have to physically re-order the data.
<GreenHillCourt@.gmail.com> wrote in message
news:a7661fdd-12e9-4a12-969f-6ec961eab992@.n1g2000prb.googlegroups.com...
>I am indexing a 32 millon row table with a unqine clustered index and
> the run time for the create index statement is over 4 hours long. This
> runs is too slow and may cost me a job If i cant find a faster way to
> create index on large table.
> Can anyone help.
|||"GreenHillCourt@.gmail.com" wrote:
> I am indexing a 32 millon row table with a unqine clustered index and
> the run time for the create index statement is over 4 hours long. This
> runs is too slow and may cost me a job If i cant find a faster way to
> create index on large table.
> Can anyone help.
- drop all unnecessary nonclustered indexes
- if possible, connect in single user mode
- add extra memory to the server, don't "pin" tables
- make sure you have enough I/O and bandwidth, both for your table, the
TempDB and the log file
- make sure you have enough free space before you start, at least 1.5
times the table size
- set the database recovery mode to simple
- choose an appropriate fillfactor. Any value below 70 is probably a bad
idea
4 hours seems excessive. How much space does the table occupy (before
you start)? What is your I/O system (number of disks, etc.)?
Gert-Jan
SQL Server MVP

'CREATE INDEX' Statement...Faster?

I am indexing a 32 millon row table with a unqine clustered index and
the run time for the create index statement is over 4 hours long. This
runs is too slow and may cost me a job If i cant find a faster way to
create index on large table.
Can anyone help.Hi
What is the version of SQL Server?
<GreenHillCourt@.gmail.com> wrote in message
news:a7661fdd-12e9-4a12-969f-6ec961eab992@.n1g2000prb.googlegroups.com...
>I am indexing a 32 millon row table with a unqine clustered index and
> the run time for the create index statement is over 4 hours long. This
> runs is too slow and may cost me a job If i cant find a faster way to
> create index on large table.
> Can anyone help.|||i don't think it would be faster. Clustered Index is the way data is stored
physically in the hard disk.
bye!
"GreenHillCourt@.gmail.com" wrote:
> I am indexing a 32 millon row table with a unqine clustered index and
> the run time for the create index statement is over 4 hours long. This
> runs is too slow and may cost me a job If i cant find a faster way to
> create index on large table.
> Can anyone help.
>|||Setting the database to simple recovery should improve compared to full recovery. At least it will
cut down on the logging. But the data shuffling still has to occur of course...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"DarthSidious" <DarthSidious@.discussions.microsoft.com> wrote in message
news:15C6F565-D67E-4912-8424-BFBDF0EC88A2@.microsoft.com...
>i don't think it would be faster. Clustered Index is the way data is stored
> physically in the hard disk.
> bye!
> "GreenHillCourt@.gmail.com" wrote:
>> I am indexing a 32 millon row table with a unqine clustered index and
>> the run time for the create index statement is over 4 hours long. This
>> runs is too slow and may cost me a job If i cant find a faster way to
>> create index on large table.
>> Can anyone help.|||<GreenHillCourt@.gmail.com> wrote in message
news:a7661fdd-12e9-4a12-969f-6ec961eab992@.n1g2000prb.googlegroups.com...
>I am indexing a 32 millon row table with a unqine clustered index and
> the run time for the create index statement is over 4 hours long. This
> runs is too slow and may cost me a job If i cant find a faster way to
> create index on large table.
As others have said, if you're creating the clustered index, not much you
can do other than perhaps look at a faster disk subsystem (say raid 10 vs
RAID 5, etc.)
If you mean you're creating a non-clustered index on a table that has an
existing clustered index, one thing that can certainly help is putting the
non-clustered index on its own set of disks.
> Can anyone help.
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html|||Have you tried creating the index without clustering? If I'm not mistaken,
it should then not have to physically re-order the data.
<GreenHillCourt@.gmail.com> wrote in message
news:a7661fdd-12e9-4a12-969f-6ec961eab992@.n1g2000prb.googlegroups.com...
>I am indexing a 32 millon row table with a unqine clustered index and
> the run time for the create index statement is over 4 hours long. This
> runs is too slow and may cost me a job If i cant find a faster way to
> create index on large table.
> Can anyone help.|||"GreenHillCourt@.gmail.com" wrote:
> I am indexing a 32 millon row table with a unqine clustered index and
> the run time for the create index statement is over 4 hours long. This
> runs is too slow and may cost me a job If i cant find a faster way to
> create index on large table.
> Can anyone help.
- drop all unnecessary nonclustered indexes
- if possible, connect in single user mode
- add extra memory to the server, don't "pin" tables
- make sure you have enough I/O and bandwidth, both for your table, the
TempDB and the log file
- make sure you have enough free space before you start, at least 1.5
times the table size
- set the database recovery mode to simple
- choose an appropriate fillfactor. Any value below 70 is probably a bad
idea
4 hours seems excessive. How much space does the table occupy (before
you start)? What is your I/O system (number of disks, etc.)?
--
Gert-Jan
SQL Server MVP

CREATE INDEX statement for SQL Mobile not documented?

Hello,

I'm unable to find documentation for the CREATE INDEX statement for SQL Mobile. DROP INDEX is documented however. Is this a known issue or am I missing something? This can be seen here:

http://msdn2.microsoft.com/en-us/library/ms173440(en-US,SQL.90).aspx

If you scroll the left pane up a little, you will notice that CREATE INDEX is not in the tree. Am I missing something?

Thanks.Thanks Ravi for catching this. And we are aware of it too.
We already have a bug opened in our Bug Database for this.

The next web site refresh should pickup the fix.

Thanks,
Laxmi NRO, MSFT, SQL Mobile, Microsoft Corporation|||Yes, the topic will be available in the December download version of SQL Server Books Online.

In the meantime, you can use the CREATE INDEX topic in the full version of Books Online : http://msdn2.microsoft.com/en-us/library/ms188783(en-US,SQL.90).aspx

Regards,|||

Finally it is live in SQL Mobile Books Online @. http://msdn2.microsoft.com/en-us/library/ms345331(en-US,SQL.90).aspx

Thanks,.

Laxmi Narsimha Rao ORUGANTI, MSFT, SQL Mobile, Microsoft Corporation

CREATE INDEX statement for SQL Mobile not documented?

Hello,

I'm unable to find documentation for the CREATE INDEX statement for SQL Mobile. DROP INDEX is documented however. Is this a known issue or am I missing something? This can be seen here:

http://msdn2.microsoft.com/en-us/library/ms173440(en-US,SQL.90).aspx

If you scroll the left pane up a little, you will notice that CREATE INDEX is not in the tree. Am I missing something?

Thanks.Thanks Ravi for catching this. And we are aware of it too.
We already have a bug opened in our Bug Database for this.

The next web site refresh should pickup the fix.

Thanks,
Laxmi NRO, MSFT, SQL Mobile, Microsoft Corporation|||Yes, the topic will be available in the December download version of SQL Server Books Online.

In the meantime, you can use the CREATE INDEX topic in the full version of Books Online : http://msdn2.microsoft.com/en-us/library/ms188783(en-US,SQL.90).aspx

Regards,|||

Finally it is live in SQL Mobile Books Online @. http://msdn2.microsoft.com/en-us/library/ms345331(en-US,SQL.90).aspx

Thanks,.

Laxmi Narsimha Rao ORUGANTI, MSFT, SQL Mobile, Microsoft Corporation

Create index question

Will creating an index while a database is in use block user access?
Thanks.If you're on SQL Server 2000, or on SQL Server 2005 with any SKU apart from
Enterprise Edition, then creating an index is an offline operation. This
means that creating a clustered index takes an exclusive table lock and
read/write access to the table is blocked. It also means that creating a
non-clustered index takes a shared table lock to block only write access to
the table.
If you're on SQL Server 2005 Enterprise Edition, you can make use of the
various online index operations, which do not hold long-term blocking
lockss. See Books Online for CREATE INDEX for more details.
Thanks
--
Paul Randal
Lead Program Manager, Microsoft SQL Server Storage Engine
http://blogs.msdn.com/sqlserverstorageengine/default.aspx
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tim Kelley" <tkelley@.company.com> wrote in message
news:uwIAu0GzGHA.3704@.TK2MSFTNGP02.phx.gbl...
> Will creating an index while a database is in use block user access?
> Thanks.
>|||It depends on what SQL Server version you are using. SQL Server 2000 and
older will block user access. In SQL Server 2005 it could be an online
operation depending on the kind of index operation you are going to perform.
See Create Index in SQL Server 2005 Books online for more details on what
index operations are online and what are offline.
Bob
"Tim Kelley" wrote:
> Will creating an index while a database is in use block user access?
> Thanks.
>
>|||Hi Tim
Even if you're using SQL 2000, you can always kill off a create index
command without much penalty so why not just try it out & kill the command
if you're blocking users too long? You might be surprised how fast some
indexes on otherwise seemingly large tables can be created..
I often use the script at the URL below with SQL 2000 to monitor blocking
from another session during index creation & just kill off the index
creation if necessary. This often gets the job done without requiring a
system outage.
http://blogs.sqlserver.org.au/blogs/greg_linwood/archive/2005/10/02/50.aspx
SQL 2005 is a different story of course, due the online indexing
capability..
Regards,
Greg Linwood
SQL Server MVP
"Tim Kelley" <tkelley@.company.com> wrote in message
news:uwIAu0GzGHA.3704@.TK2MSFTNGP02.phx.gbl...
> Will creating an index while a database is in use block user access?
> Thanks.
>

Create index question

Will creating an index while a database is in use block user access?
Thanks.If you're on SQL Server 2000, or on SQL Server 2005 with any SKU apart from
Enterprise Edition, then creating an index is an offline operation. This
means that creating a clustered index takes an exclusive table lock and
read/write access to the table is blocked. It also means that creating a
non-clustered index takes a shared table lock to block only write access to
the table.
If you're on SQL Server 2005 Enterprise Edition, you can make use of the
various online index operations, which do not hold long-term blocking
lockss. See Books Online for CREATE INDEX for more details.
Thanks
Paul Randal
Lead Program Manager, Microsoft SQL Server Storage Engine
http://blogs.msdn.com/sqlserverstor...ne/default.aspx
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tim Kelley" <tkelley@.company.com> wrote in message
news:uwIAu0GzGHA.3704@.TK2MSFTNGP02.phx.gbl...
> Will creating an index while a database is in use block user access?
> Thanks.
>|||It depends on what SQL Server version you are using. SQL Server 2000 and
older will block user access. In SQL Server 2005 it could be an online
operation depending on the kind of index operation you are going to perform.
See Create Index in SQL Server 2005 Books online for more details on what
index operations are online and what are offline.
Bob
"Tim Kelley" wrote:

> Will creating an index while a database is in use block user access?
> Thanks.
>
>|||Hi Tim
Even if you're using SQL 2000, you can always kill off a create index
command without much penalty so why not just try it out & kill the command
if you're blocking users too long? You might be surprised how fast some
indexes on otherwise seemingly large tables can be created..
I often use the script at the URL below with SQL 2000 to monitor blocking
from another session during index creation & just kill off the index
creation if necessary. This often gets the job done without requiring a
system outage.
http://blogs.sqlserver.org.au/blogs...5/10/02/50.aspx
SQL 2005 is a different story of course, due the online indexing
capability..
Regards,
Greg Linwood
SQL Server MVP
"Tim Kelley" <tkelley@.company.com> wrote in message
news:uwIAu0GzGHA.3704@.TK2MSFTNGP02.phx.gbl...
> Will creating an index while a database is in use block user access?
> Thanks.
>

Create Index option in the table designer

Hi All,
In the table designer, I don't seem to find any option to create indexes.
Can indexes on tables be only created using the SQL Query Analyser?
kd
In Enterprise Manager, right click on the table and select
All Tasks and then Manage Indexes. Click on the new button
to create a new index.
If you are in design view of a table, you can right click in
the designer and select Indexes/Keys.
-Sue
On Mon, 11 Apr 2005 03:51:01 -0700, "kd"
<kd@.discussions.microsoft.com> wrote:

>Hi All,
>In the table designer, I don't seem to find any option to create indexes.
>Can indexes on tables be only created using the SQL Query Analyser?
>kd

create index on table

Hi,
What's the difference/performance difference when you
create a index with two columns combined vs create two
indexes with each one of them as showed below?
1.
CREATE INDEX [index1] ON [dbo].[table1]([MARKET], [DATE])
WITH FILLFACTOR = 75 ON [primary]
2.
CREATE INDEX [index1] ON [dbo].[table1]([MARKET]) WITH
FILLFACTOR = 75 ON [primary]
CREATE INDEX [index1] ON [dbo].[table1]([DATE]) WITH
FILLFACTOR = 75 ON [primary]
thanks a lot!
JJ
One Index with both columns will provide roughly the same index relief as
two individual columns.
Two separate indexes adds over head as each individual index has to be
maintained by SQL Server.
Greg Jackson
PDX, Oregon
|||"JJ Wang" <anonymous@.discussions.microsoft.com> wrote in message
news:122f001c4429d$86cb8500$a301280a@.phx.gbl...
> Hi,
> What's the difference/performance difference when you
> create a index with two columns combined vs create two
> indexes with each one of them as showed below?
>
An index can only be accessed by its leading column(s). So an index on two
columns is usefull when accessing the table by the leading column of the
index or both the columns of the index. But an index on two columns cannot
be used when accessing the table by the second columns of the index only.
So in your example
CREATE INDEX [index1] ON [dbo].[table1]([MARKET], [DATE])
WITH FILLFACTOR = 75 ON [primary]
index1 cannot be used to filter
select * from table1 where date = '2002-05-05'
but can be used to filter
select * from table1 where market = 3 and date = '2002-05-05'
and a query of the form
select market, date from table1 where market = 1
is covered by the query and can be processed completely from the index
without hitting the base table.
On the other hand two seperate indexes have more overhead, and don't do
particularly well with queries which specify both columns, as either index
may be used but not both.
select * from table1 where market = 3 and date = '2002-05-05'
David
|||Actually that is not quite true on two counts. The idea is correct but the
details are misleading.

> An index can only be accessed by its leading column(s). So an index on
two
SQL Server can actually still use the index when searching for the second
column but not with a SEEK, only a SCAN. If no other index is available it
may be cheaper to scan the compound index than scanning the entire table.
But obviously this is not the recommended way to do this.

> On the other hand two separate indexes have more overhead, and don't do
> particularly well with queries which specify both columns, as either index
> may be used but not both.
This is not totally true either. SQL Server can in fact use two separate
indexes in what is called "Index Intersection" to find common rows between
the two indexes. So if you do have a situation where you need to search on
both columns individually it is often helpful to have two separate indexes.
Sometimes you may find having a compound index and a second one with a
single column useful as well. As always it depends.
Andrew J. Kelly
SQL Server MVP
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:%23UTTNJqQEHA.644@.tk2msftngp13.phx.gbl...
> "JJ Wang" <anonymous@.discussions.microsoft.com> wrote in message
> news:122f001c4429d$86cb8500$a301280a@.phx.gbl...
> An index can only be accessed by its leading column(s). So an index on
two
> columns is usefull when accessing the table by the leading column of the
> index or both the columns of the index. But an index on two columns
cannot
> be used when accessing the table by the second columns of the index only.
> So in your example
> CREATE INDEX [index1] ON [dbo].[table1]([MARKET], [DATE])
> WITH FILLFACTOR = 75 ON [primary]
> index1 cannot be used to filter
> select * from table1 where date = '2002-05-05'
> but can be used to filter
> select * from table1 where market = 3 and date = '2002-05-05'
> and a query of the form
> select market, date from table1 where market = 1
> is covered by the query and can be processed completely from the index
> without hitting the base table.
>
> On the other hand two seperate indexes have more overhead, and don't do
> particularly well with queries which specify both columns, as either index
> may be used but not both.
> select * from table1 where market = 3 and date = '2002-05-05'
> David
>

create index on table

Hi,
What's the difference/performance difference when you
create a index with two columns combined vs create two
indexes with each one of them as showed below?
1.
CREATE INDEX [index1] ON [dbo].[table1]([MARKET], [DATE
])
WITH FILLFACTOR = 75 ON [primary]
2.
CREATE INDEX [index1] ON [dbo].[table1]([MARKET]) WITH
FILLFACTOR = 75 ON [primary]
CREATE INDEX [index1] ON [dbo].[table1]([DATE]) WITH
FILLFACTOR = 75 ON [primary]
thanks a lot!
JJOne Index with both columns will provide roughly the same index relief as
two individual columns.
Two separate indexes adds over head as each individual index has to be
maintained by SQL Server.
Greg Jackson
PDX, Oregon|||"JJ Wang" <anonymous@.discussions.microsoft.com> wrote in message
news:122f001c4429d$86cb8500$a301280a@.phx
.gbl...
> Hi,
> What's the difference/performance difference when you
> create a index with two columns combined vs create two
> indexes with each one of them as showed below?
>
An index can only be accessed by its leading column(s). So an index on two
columns is usefull when accessing the table by the leading column of the
index or both the columns of the index. But an index on two columns cannot
be used when accessing the table by the second columns of the index only.
So in your example
CREATE INDEX [index1] ON [dbo].[table1]([MARKET], [DATE
])
WITH FILLFACTOR = 75 ON [primary]
index1 cannot be used to filter
select * from table1 where date = '2002-05-05'
but can be used to filter
select * from table1 where market = 3 and date = '2002-05-05'
and a query of the form
select market, date from table1 where market = 1
is covered by the query and can be processed completely from the index
without hitting the base table.
On the other hand two seperate indexes have more overhead, and don't do
particularly well with queries which specify both columns, as either index
may be used but not both.
select * from table1 where market = 3 and date = '2002-05-05'
David|||Actually that is not quite true on two counts. The idea is correct but the
details are misleading.

> An index can only be accessed by its leading column(s). So an index on
two
SQL Server can actually still use the index when searching for the second
column but not with a SEEK, only a SCAN. If no other index is available it
may be cheaper to scan the compound index than scanning the entire table.
But obviously this is not the recommended way to do this.

> On the other hand two separate indexes have more overhead, and don't do
> particularly well with queries which specify both columns, as either index
> may be used but not both.
This is not totally true either. SQL Server can in fact use two separate
indexes in what is called "Index Intersection" to find common rows between
the two indexes. So if you do have a situation where you need to search on
both columns individually it is often helpful to have two separate indexes.
Sometimes you may find having a compound index and a second one with a
single column useful as well. As always it depends.
Andrew J. Kelly
SQL Server MVP
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:%23UTTNJqQEHA.644@.tk2msftngp13.phx.gbl...
> "JJ Wang" <anonymous@.discussions.microsoft.com> wrote in message
> news:122f001c4429d$86cb8500$a301280a@.phx
.gbl...
> An index can only be accessed by its leading column(s). So an index on
two
> columns is usefull when accessing the table by the leading column of the
> index or both the columns of the index. But an index on two columns
cannot
> be used when accessing the table by the second columns of the index only.
> So in your example
> CREATE INDEX [index1] ON [dbo].[table1]([MARKET], [DA
TE])
> WITH FILLFACTOR = 75 ON [primary]
> index1 cannot be used to filter
> select * from table1 where date = '2002-05-05'
> but can be used to filter
> select * from table1 where market = 3 and date = '2002-05-05'
> and a query of the form
> select market, date from table1 where market = 1
> is covered by the query and can be processed completely from the index
> without hitting the base table.
>
> On the other hand two seperate indexes have more overhead, and don't do
> particularly well with queries which specify both columns, as either index
> may be used but not both.
> select * from table1 where market = 3 and date = '2002-05-05'
> David
>

create index on table

Hi,
What's the difference/performance difference when you
create a index with two columns combined vs create two
indexes with each one of them as showed below?
1.
CREATE INDEX [index1] ON [dbo].[table1]([MARKET], [DATE])
WITH FILLFACTOR = 75 ON [primary]
2.
CREATE INDEX [index1] ON [dbo].[table1]([MARKET]) WITH
FILLFACTOR = 75 ON [primary]
CREATE INDEX [index1] ON [dbo].[table1]([DATE]) WITH
FILLFACTOR = 75 ON [primary]
thanks a lot!
JJOne Index with both columns will provide roughly the same index relief as
two individual columns.
Two separate indexes adds over head as each individual index has to be
maintained by SQL Server.
Greg Jackson
PDX, Oregon|||"JJ Wang" <anonymous@.discussions.microsoft.com> wrote in message
news:122f001c4429d$86cb8500$a301280a@.phx.gbl...
> Hi,
> What's the difference/performance difference when you
> create a index with two columns combined vs create two
> indexes with each one of them as showed below?
>
An index can only be accessed by its leading column(s). So an index on two
columns is usefull when accessing the table by the leading column of the
index or both the columns of the index. But an index on two columns cannot
be used when accessing the table by the second columns of the index only.
So in your example
CREATE INDEX [index1] ON [dbo].[table1]([MARKET], [DATE])
WITH FILLFACTOR = 75 ON [primary]
index1 cannot be used to filter
select * from table1 where date = '2002-05-05'
but can be used to filter
select * from table1 where market = 3 and date = '2002-05-05'
and a query of the form
select market, date from table1 where market = 1
is covered by the query and can be processed completely from the index
without hitting the base table.
On the other hand two seperate indexes have more overhead, and don't do
particularly well with queries which specify both columns, as either index
may be used but not both.
select * from table1 where market = 3 and date = '2002-05-05'
David|||Actually that is not quite true on two counts. The idea is correct but the
details are misleading.
> An index can only be accessed by its leading column(s). So an index on
two
SQL Server can actually still use the index when searching for the second
column but not with a SEEK, only a SCAN. If no other index is available it
may be cheaper to scan the compound index than scanning the entire table.
But obviously this is not the recommended way to do this.
> On the other hand two separate indexes have more overhead, and don't do
> particularly well with queries which specify both columns, as either index
> may be used but not both.
This is not totally true either. SQL Server can in fact use two separate
indexes in what is called "Index Intersection" to find common rows between
the two indexes. So if you do have a situation where you need to search on
both columns individually it is often helpful to have two separate indexes.
Sometimes you may find having a compound index and a second one with a
single column useful as well. As always it depends.
--
Andrew J. Kelly
SQL Server MVP
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:%23UTTNJqQEHA.644@.tk2msftngp13.phx.gbl...
> "JJ Wang" <anonymous@.discussions.microsoft.com> wrote in message
> news:122f001c4429d$86cb8500$a301280a@.phx.gbl...
> > Hi,
> >
> > What's the difference/performance difference when you
> > create a index with two columns combined vs create two
> > indexes with each one of them as showed below?
> >
> An index can only be accessed by its leading column(s). So an index on
two
> columns is usefull when accessing the table by the leading column of the
> index or both the columns of the index. But an index on two columns
cannot
> be used when accessing the table by the second columns of the index only.
> So in your example
> CREATE INDEX [index1] ON [dbo].[table1]([MARKET], [DATE])
> WITH FILLFACTOR = 75 ON [primary]
> index1 cannot be used to filter
> select * from table1 where date = '2002-05-05'
> but can be used to filter
> select * from table1 where market = 3 and date = '2002-05-05'
> and a query of the form
> select market, date from table1 where market = 1
> is covered by the query and can be processed completely from the index
> without hitting the base table.
>
> On the other hand two seperate indexes have more overhead, and don't do
> particularly well with queries which specify both columns, as either index
> may be used but not both.
> select * from table1 where market = 3 and date = '2002-05-05'
> David
>|||wow! you are all so knowledgable! thank you so much for
being so helpful!
JJ
>--Original Message--
>Hi,
>What's the difference/performance difference when you
>create a index with two columns combined vs create two
>indexes with each one of them as showed below?
>1.
>CREATE INDEX [index1] ON [dbo].[table1]([MARKET],
[DATE])
>WITH FILLFACTOR = 75 ON [primary]
>2.
>CREATE INDEX [index1] ON [dbo].[table1]([MARKET]) WITH
>FILLFACTOR = 75 ON [primary]
>CREATE INDEX [index1] ON [dbo].[table1]([DATE]) WITH
>FILLFACTOR = 75 ON [primary]
>
>thanks a lot!
>JJ
>.
>|||wow! you are all so knowledgable! thank you so much for
being so helpful!
JJ
>--Original Message--
>Hi,
>What's the difference/performance difference when you
>create a index with two columns combined vs create two
>indexes with each one of them as showed below?
>1.
>CREATE INDEX [index1] ON [dbo].[table1]([MARKET],
[DATE])
>WITH FILLFACTOR = 75 ON [primary]
>2.
>CREATE INDEX [index1] ON [dbo].[table1]([MARKET]) WITH
>FILLFACTOR = 75 ON [primary]
>CREATE INDEX [index1] ON [dbo].[table1]([DATE]) WITH
>FILLFACTOR = 75 ON [primary]
>
>thanks a lot!
>JJ
>.
>

CREATE INDEX on large table

SQL Server 7/2000: We have reasonably large tables (3,000,000 rows)
that we need to add some indexes for. In a test, it took over 12 hours
to CREATE a new INDEX against this table. One of us suggested that we
create a temp table with the new index and copy the data from the old
table into the new one, then rename it. I understand this took 15
minutes. Why the heck would it be faster to move the data and build
multiple indexes incrementally vs adding an index??An index on a sorted table is quicker as the indexing process does not need
to reorganized it as its creating the index.

"dfurtney" <dfurtney@.hotmail.com> wrote in message
news:1105492090.497574.233360@.z14g2000cwz.googlegr oups.com...
> SQL Server 7/2000: We have reasonably large tables (3,000,000 rows)
> that we need to add some indexes for. In a test, it took over 12 hours
> to CREATE a new INDEX against this table. One of us suggested that we
> create a temp table with the new index and copy the data from the old
> table into the new one, then rename it. I understand this took 15
> minutes. Why the heck would it be faster to move the data and build
> multiple indexes incrementally vs adding an index??|||Hi

This seems unlikely.
You did not mention if the table is a heap (i.e. there is no clustered
index).
You probably ran into a case where the data in the old table was so out
of order that building the additional index was constatnly splitting
pages.|||dfurtney (dfurtney@.hotmail.com) writes:
> SQL Server 7/2000: We have reasonably large tables (3,000,000 rows)
> that we need to add some indexes for. In a test, it took over 12 hours
> to CREATE a new INDEX against this table. One of us suggested that we
> create a temp table with the new index and copy the data from the old
> table into the new one, then rename it. I understand this took 15
> minutes. Why the heck would it be faster to move the data and build
> multiple indexes incrementally vs adding an index??

12 hours to create an index for three million rows sounds abnormal.

Of course, if the table did not have a clustered index, but already had
several non-clustered index, and you added a clustered index, then it
will take some time, but still not 12 hours.

One possible reason, is that the CREATE INDEX process was blocked by
another process most of the time.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||The table, vehicle_history, had a clustered primary key and 2
additional indexes. We were adding an additional index on a single
integer column. That column was filled with a single default value of
0 in this case. It was running on a dedicated QA server.

We want to add this index to speed up a query against the new column.
But we found it was taking much longer than we expected to add the
index. The only thing that seemed somewhat unusual is the size of the
table.|||dfurtney (dfurtney@.hotmail.com) writes:
> The table, vehicle_history, had a clustered primary key and 2
> additional indexes. We were adding an additional index on a single
> integer column. That column was filled with a single default value of
> 0 in this case. It was running on a dedicated QA server.
> We want to add this index to speed up a query against the new column.
> But we found it was taking much longer than we expected to add the
> index. The only thing that seemed somewhat unusual is the size of the
> table.

Does all three million rows have 0 in this column? In that case it would
not be a very good index.

I have no idea whether large amount of duplicate values could be reason
that creating the index so long. I still lean towards that there was some-
thing else, for instance blocking, that was the cause. It simply doesn't
take 12 hours to create a non-clustered index on a three-million row table.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||The query/index would be used by a subset of our customers that utilize
a specific feature of the product. For them, the values would be
non-zero, of course, and the resulting index quite selective. However,
we were going to add the index for all customers since we generally
don't know what functionaly they will be utilizing. This dataset was
from a customer not using that function.

I thought it was awfully long and one of my co-workers was going to do
some testing. What order of time would you expect?|||dfurtney (dfurtney@.hotmail.com) writes:
> The query/index would be used by a subset of our customers that utilize
> a specific feature of the product. For them, the values would be
> non-zero, of course, and the resulting index quite selective. However,
> we were going to add the index for all customers since we generally
> don't know what functionaly they will be utilizing. This dataset was
> from a customer not using that function.
> I thought it was awfully long and one of my co-workers was going to do
> some testing. What order of time would you expect?

The below script which emulates the situation you have described ran
in eight minutes on my workstation, a 2.8 GHz HT box with 1 GB of RAM
(but with SQL Server constrained to some 120 MB), running Windows XP SP2.
The particular part of creating a non-clustered index on a column with
non-variant values took 30 seconds. (But then all data was in cache.)

Of course, not only number of rows count, but the size of the rows as
well, since wider the rows, the more pages you get. Then again, for
the sorting phase there are still only three million rows.

It occurred to me that one thing you could have run into is autogrow.
If the database is 300 GB, and you have 10% autogrow and this happens to
set in during the index creation, you're in for a pause. Initializing
30 GB of data does take some time. Not 12 hours though. 20-30 minutes
may be expected.

use master
go
drop database klump
go
create database klump
go
use klump
go
select TOP 3000000 klumpid = identity(int, 1, 1),
slaskcol = 0,
a.* into klump
from Northwind..Orders a
cross join Northwind..Orders b
cross join Northwind..Orders c
go
ALTER TABLE klump ADD CONSTRAINT pk_klump PRIMARY KEY (klumpid)
go
CREATE INDEX orderidix ON klump (OrderID)
CREATE INDEX customerid ON klump (CustomerID)
go
SELECT getdate()
go
CREATE INDEX slaskix ON klump(slaskcol)
go
SELECT getdate()

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Although this happened twice on two machines when analyzing the upgrade
script via profiler -- our latest attempts to isolate what is happening
ended up not reproducing our earlier results. The indexes are building
in 2 minutes when tested in isolation outside the script. The only
operation which we have reliably reproduced as slow is adding a column
with a default value to a large table - which is taking on the order of
20 minutes in the million row range. We do this a number of times. We
don't yet have an explanation for why the script took so long, although
we are running the analysis one more time as I speak.

Sorry to have presented you with a problem that didn't reproduce - but
we were about to make some drastic changes based on the faulty
assumption that building million row indexes was much more expensive
then it really is. I appreciate the help you folks have provided!|||dfurtney (dfurtney@.hotmail.com) writes:
> Although this happened twice on two machines when analyzing the upgrade
> script via profiler -- our latest attempts to isolate what is happening
> ended up not reproducing our earlier results. The indexes are building
> in 2 minutes when tested in isolation outside the script. The only
> operation which we have reliably reproduced as slow is adding a column
> with a default value to a large table - which is taking on the order of
> 20 minutes in the million row range. We do this a number of times.

This sounds like a perfectly normal time for such an operation. Since
this column has to be copied into every row, the entire table has to
be rewritten. And unless every page bas bytes to spare for the new column,
you also get rows rearranged, and it is not a simple update in place.

In this case, it can sometimes be better to create a new table and
copy data over. (This in fact what we always do in our update scripts,
although that more has to do with the greater flexibility this
technique offers.)

> Sorry to have presented you with a problem that didn't reproduce - but
> we were about to make some drastic changes based on the faulty
> assumption that building million row indexes was much more expensive
> then it really is. I appreciate the help you folks have provided!

Oh, never mind! I think your concern was very valid, and I am glad to
have helped by telling you that it must have been a false alarm.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||I suggest the real issue is:

> The only operation which we have reliably reproduced as slow is
adding a column
> with a default value to a large table - which is taking on the order
of
> 20 minutes in the million row range. We do this a number of times.

Why would you frequently add columns to a three million row table?

As far as selectivity goes, you don't gain any advantage to having a
default value of 0 vs. having a default value of NULL - it is a
disadvantage because you are frequently adding columns to a 3,000,000
row table. If the default value is NULL, SQL Server does not have to
rebuild the table when you add the value - NULL is nothing as far as
SQL Server is concerned.

The statistics histogram, based on only a select few companies having
this feature, would look something like:
_________________________||||Point well taken regarding NULL vs 0. The reason we use 0 instead of
NULL is because most of the software and reporting is "confused" by
nulls. MFC recordsets return the inconvenient tvalue of

#define AFX_RFX_LONG_PSEUDO_NULL (0x4a4d4120L)

for null integers unless you specifically write code to check for null.
We have a large, old codebase which has no null handling code.

This is a function/service pack, so we commonly add a number of new
fields to support new functionality. In our 3rd test, the upgrade
script took 3 hours - which is in the "normal" range. I guess we are
going to attribute the earlier results as anomalous for now and monitor
for another occurrence. The index is useless for customers not
utilizing the feature, however, if the cost is only 2 minutes, it is
easier to just add the index for all customers. For those customers
using the feature/index, it is highly selective.

Create index on col with data and without data, any time differenc

Hello:
In terms of the time it takes to create an index (non-clustered) in a
column, would it be faster if the column contains only null? Or the time it
takes to create an index will be the same whether this column has data or not.
Thanks,
Q
Hi
I don't think there will be a significant difference in the time taken to
create the index, but if you then significantly change the data in the
column, the index may be fragmented and the statistics out of date, therefore
it would be better to build the index once populated.
John
"Q" wrote:

> Hello:
> In terms of the time it takes to create an index (non-clustered) in a
> column, would it be faster if the column contains only null? Or the time it
> takes to create an index will be the same whether this column has data or not.
> Thanks,
> Q
|||No rows are omitted from an index. Not even rows where the indexed
column is NULL. So the time to index the column would be the same,
regardless of any value (or NULL) (assuming fixed size data type).
Gert-Jan
Q wrote:
> Hello:
> In terms of the time it takes to create an index (non-clustered) in a
> column, would it be faster if the column contains only null? Or the time it
> takes to create an index will be the same whether this column has data or not.
> Thanks,
> Q

Create index on col with data and without data, any time differenc

Hello:
In terms of the time it takes to create an index (non-clustered) in a
column, would it be faster if the column contains only null? Or the time it
takes to create an index will be the same whether this column has data or no
t.
Thanks,
QHi
I don't think there will be a significant difference in the time taken to
create the index, but if you then significantly change the data in the
column, the index may be fragmented and the statistics out of date, therefor
e
it would be better to build the index once populated.
John
"Q" wrote:

> Hello:
> In terms of the time it takes to create an index (non-clustered) in a
> column, would it be faster if the column contains only null? Or the time
it
> takes to create an index will be the same whether this column has data or
not.
> Thanks,
> Q|||No rows are omitted from an index. Not even rows where the indexed
column is NULL. So the time to index the column would be the same,
regardless of any value (or NULL) (assuming fixed size data type).
Gert-Jan
Q wrote:
> Hello:
> In terms of the time it takes to create an index (non-clustered) in a
> column, would it be faster if the column contains only null? Or the time
it
> takes to create an index will be the same whether this column has data or
not.
> Thanks,
> Q

Create index on col with data and without data, any time differenc

Hello:
In terms of the time it takes to create an index (non-clustered) in a
column, would it be faster if the column contains only null? Or the time it
takes to create an index will be the same whether this column has data or not.
Thanks,
QHi
I don't think there will be a significant difference in the time taken to
create the index, but if you then significantly change the data in the
column, the index may be fragmented and the statistics out of date, therefore
it would be better to build the index once populated.
John
"Q" wrote:
> Hello:
> In terms of the time it takes to create an index (non-clustered) in a
> column, would it be faster if the column contains only null? Or the time it
> takes to create an index will be the same whether this column has data or not.
> Thanks,
> Q|||No rows are omitted from an index. Not even rows where the indexed
column is NULL. So the time to index the column would be the same,
regardless of any value (or NULL) (assuming fixed size data type).
Gert-Jan
Q wrote:
> Hello:
> In terms of the time it takes to create an index (non-clustered) in a
> column, would it be faster if the column contains only null? Or the time it
> takes to create an index will be the same whether this column has data or not.
> Thanks,
> Q