Showing posts with label insert. Show all posts
Showing posts with label insert. Show all posts

Wednesday, March 28, 2012

InfoPath 2003 - insert data in SQLServer?

Hello,

I created an InfoPath 2003 form, with a datasource from SqlServer 2000. When I try to insert a new record the follow error occurs:

"InfoPath cannot connect to the data source.
Safety settings on this computer prohibit accessing a data source on another domain."

I checked Enabled -"Access data source accross domains" from Security Settings->Miscellaneous, but the error still appears.

Have anyone any idea about this error?

Thanks.


This seems like an InfoPath specific configuration issue. You may want to try re-posting (sorry, I couldn't find a forum to which I could simply move this post) your question to the InfoPath newsgroup at http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.infopath or checking out the InfoPath blog at http://blogs.msdn.com/infopath/default.aspx.

sql

Friday, March 23, 2012

inesert null value

Hi All,

I am using c# (asp.net 2.0) and sql 2005.

I need to check whether the checkbox is checked then insert the current date or insert a empty/null values.

I used this condition chkTFR.Checked ?DateTime.Now :SqlDateTime.Null.Value or chkTFR.Checked ?DateTime.Now :System.DBNull.Value

In the database table I create a field with datetime type. I am not able to insert a null value to the field. If anybody had an experience pls post your code.

I am using strongly typed dataset & tableadapter to insert the values to the database table. (for your reference C this link:http://www.asp.net/learn/data-access/tutorial-01-cs.aspx)

ThanX in advance

Brotherly

~FAAS

The article in the following link covers your issue:

http://www.c-sharpcorner.com/UploadFile/sd_patel/EnterNullValuesForDateTime11222005015742AM/EnterNullValuesForDateTime.aspx

|||

Hi,

I used

SqlDateTime.Null.Value

I got this error message when I press the submit button.

Data is Null. This method or property cannot be called on Null values.

Remember I am using the strongly Typed DataSet & TableAdapter method.

Regards

~FAAS

|||

Hi faas1,

I guess you are using tableadpter database direct methods to insert data (like, tableadapter.Insert(your insert value)).

You can try to use "null" instread ofSqlDateTime.Null.Value /DBNull.value in your Insert() method. I've tested in my side and it works fine.

Hope my suggestion helps

inerting/updating a collection of data values into SQL Server db all at once.

I'd like to insert/update a collection of data values from VS2005 (C#) into sql server in one insert/update statement. For instance, I'd like to insert all values from a checkboxlist that are checked without having to perform an insert statement for each value. What's the best way to go about this?

thx.

Assuming that you have the list as a joined string array, you could something like this with the following function I once wrote:

CREATE FUNCTION dbo.Split

(

@.String VARCHAR(200),

@.Delimiter VARCHAR(5)

)

RETURNS @.SplittedValues TABLE

(

OccurenceId SMALLINT IDENTITY(1,1),

SplitValue VARCHAR(200)

)

AS

BEGIN

DECLARE @.SplitLength INT

WHILE LEN(@.String) > 0

BEGIN

SELECT @.SplitLength = (CASE CHARINDEX(@.Delimiter,@.String) WHEN 0 THEN

LEN(@.String) ELSE CHARINDEX(@.Delimiter,@.String) -1 END)

INSERT INTO @.SplittedValues

SELECT SUBSTRING(@.String,1,@.SplitLength)

SELECT @.String = (CASE (LEN(@.String) - @.SplitLength) WHEN 0 THEN ''

ELSE RIGHT(@.String, LEN(@.String) - @.SplitLength - 1) END)

END

RETURN

END

So this would evaluate in your case to:

Set @.ListOfIDs = '1, 2, 3, 4, 5'

INSERT INTO SomeTable
(Column)
Select SplitValue From dbo.Split(@.ListOfIDs,',')

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

|||I thought that SQL Server 2005 allowed the insertion of VS 2005 DataTables etc. no?|||

MarilynJ wrote:

I'd like to insert/update a collection of data values from VS2005 (C#) into sql server in one insert/update statement. For instance, I'd like to insert all values from a checkboxlist that are checked without having to perform an insert statement for each value. What's the best way to go about this?

thx.

fill the dataset from data from sql server

update on the front end. vs2005 is using twoway binding

so there's not much work to be done

then

call the tableadapter update method

to commit chages to the database as a batch.

this is known as batch update

|||And remember that i you are working completly disconnected from the database that you have to specify your own Commands to update / insert / delete the data. Otherwise you could use the commandbuilder which will get you the appropiate commands if you read the schema from the database.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.desql

Ineed the Right Syntax

Hello,

I need the Right Syntax of this Staement

IF(select count(*) from Department where Department_Id=@.De_Id)=0

begin

insert into Depatment vaule.....etc

esle

update

end

just i have problem with the syntax of first If Statement

Something like this would be a bit more efficient.

Searching stops when the first row is encountered, whereas SELECT count(*) has to search the entire filtered set.

Also, 'IF' does not require an 'END' as in Visual Basic.

Code Snippet

IF EXISTS

( SELECT 1

FROM Department

WHERE Department_ID = @.De_ID

)

INSERT INTO Department ( Columns )

VALUES ( @.Values )

ELSE

UPDATE Department

SET

Column1 = @.Value1,

etc.

|||

For anyone who is currently doing the first touch to the new version of SQL Server 2008, you should try the MERGE statement (aka UPSERT) which was requested for many of the previous version and is finally implemented.

Jens K. Suessmeyer.


http://www.sqlserver2005.de

Wednesday, March 21, 2012

Indexing table-valued function?

I am using a multi-statement table-valued function to assemble data from several tables and views for a report. To do this, I INSERT data into the first few columns and then use UPDATEs to put data additional data into each row. Each UPDATE uses a WHERE criteria that identifies a unique row, based on the value of the first few columns.

The problem I'm having is that the UPDATEs are taking forever to execute. I believe the reason is that the temporary table that's created for the function is not indexed, so each row update requires a complete search of several columns.

In other situations I've been able to define one column as a primary key for the temporary table, but in this situation the primary key would have to consist of four columns, which doesn't seem to be allowed in the table definition for the function.

Is there any way to create indexes for the temporary tables that are created for multistatement table-valued functions? I think that would improve the UPDATE performance dramatically.

Thanks,

Lee Silverman
JackRabbit Sports

-Is it not possible to insert the data with one sql statement that would join all the needed tables together?

-Yes, temporary tables can be indexed just like regular tables.

Code Snippet

create unique clustered idex [IX_TestIndex] on #TmpTable (colA, colB, colC, colD)

Monday, March 19, 2012

Indexing problem

Dear all
I have a table which contains ~ 11 million rows in it.
I drop the indexes, bulk insert the data into it and then rebuild the
indexes.
Whilst building the indexes, the server (dual xeon 2.8 GHz) maxes out at
100 CPU on both processors for ~ 10 minutes and then the whole server
re-boots There are 3 indexes to be built, it crashes whilst building the
third.
However, if I run the three steps one at a time, the server survives.
I have backed up the database and copied it to an identical server and
loaded the same data in and again that server reboots. However, if I copy
the DB and the data to my PC (single 2.6 GHz p4 processor) it works fine.
It also doesn't flat line at 100% cpu but instead the CPU follows a cyclic
pattern. I can't get my PC to crash...
Any ideas?
Griffso there are really two question.
1. How to optimize an index build.
2. why is the server crashing. Anything in the logs (os or SQL). Any more
details?
Unqueestionably.. .THAT is a bug. Now, it might be a MS bug, or it might be
a hardware bug. If it's a MS bug and you open a call to MS product support
the call will be free. If it's a hardware bug (perhaps your server IO isn't
on the HCL?) then you'd end up eating the cost...
You might want to take a look at SQLIO from MS. I don't have the URL, but
it's an IO stress tool. It simulates SQL Server IO... it will mostly likely
cause the server to crash if in fact SQL IO stress is causing the server to
crash under an index build...
Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"GriffithsJ" <GriffithsJ_520@.hotmail.com> wrote in message
news:Oofq5o0PEHA.3420@.TK2MSFTNGP11.phx.gbl...
> Dear all
> I have a table which contains ~ 11 million rows in it.
> I drop the indexes, bulk insert the data into it and then rebuild the
> indexes.
> Whilst building the indexes, the server (dual xeon 2.8 GHz) maxes out at
> 100 CPU on both processors for ~ 10 minutes and then the whole server
> re-boots There are 3 indexes to be built, it crashes whilst building the
> third.
> However, if I run the three steps one at a time, the server survives.
> I have backed up the database and copied it to an identical server and
> loaded the same data in and again that server reboots. However, if I copy
> the DB and the data to my PC (single 2.6 GHz p4 processor) it works fine.
> It also doesn't flat line at 100% cpu but instead the CPU follows a cyclic
> pattern. I can't get my PC to crash...
> Any ideas?
> Griff
>|||Griff,
Are you running Enterprise Edition or Standard Edition? Enterprise
Edition supports Parallel index creation. Maybe you hit a bug, and are
not running Enterprise Edition on your PC.
Needless to say you need to install the latest service packs. Some bugs
are fixed...
http://support.microsoft.com/defaul...kb;EN-US;279295
Gert-Jan
GriffithsJ wrote:
> Dear all
> I have a table which contains ~ 11 million rows in it.
> I drop the indexes, bulk insert the data into it and then rebuild the
> indexes.
> Whilst building the indexes, the server (dual xeon 2.8 GHz) maxes out at
> 100 CPU on both processors for ~ 10 minutes and then the whole server
> re-boots There are 3 indexes to be built, it crashes whilst building the
> third.
> However, if I run the three steps one at a time, the server survives.
> I have backed up the database and copied it to an identical server and
> loaded the same data in and again that server reboots. However, if I copy
> the DB and the data to my PC (single 2.6 GHz p4 processor) it works fine.
> It also doesn't flat line at 100% cpu but instead the CPU follows a cyclic
> pattern. I can't get my PC to crash...
> Any ideas?
> Griff
(Please reply only to the newsgroup)

Indexing problem

Dear all
I have a table which contains ~ 11 million rows in it.
I drop the indexes, bulk insert the data into it and then rebuild the
indexes.
Whilst building the indexes, the server (dual xeon 2.8 GHz) maxes out at
100 CPU on both processors for ~ 10 minutes and then the whole server
re-boots There are 3 indexes to be built, it crashes whilst building the
third.
However, if I run the three steps one at a time, the server survives.
I have backed up the database and copied it to an identical server and
loaded the same data in and again that server reboots. However, if I copy
the DB and the data to my PC (single 2.6 GHz p4 processor) it works fine.
It also doesn't flat line at 100% cpu but instead the CPU follows a cyclic
pattern. I can't get my PC to crash...
Any ideas?
Griffso there are really two question.
1. How to optimize an index build.
2. why is the server crashing. Anything in the logs (os or SQL). Any more
details?
Unqueestionably.. .THAT is a bug. Now, it might be a MS bug, or it might be
a hardware bug. If it's a MS bug and you open a call to MS product support
the call will be free. If it's a hardware bug (perhaps your server IO isn't
on the HCL?) then you'd end up eating the cost...
You might want to take a look at SQLIO from MS. I don't have the URL, but
it's an IO stress tool. It simulates SQL Server IO... it will mostly likely
cause the server to crash if in fact SQL IO stress is causing the server to
crash under an index build...
--
Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"GriffithsJ" <GriffithsJ_520@.hotmail.com> wrote in message
news:Oofq5o0PEHA.3420@.TK2MSFTNGP11.phx.gbl...
> Dear all
> I have a table which contains ~ 11 million rows in it.
> I drop the indexes, bulk insert the data into it and then rebuild the
> indexes.
> Whilst building the indexes, the server (dual xeon 2.8 GHz) maxes out at
> 100 CPU on both processors for ~ 10 minutes and then the whole server
> re-boots There are 3 indexes to be built, it crashes whilst building the
> third.
> However, if I run the three steps one at a time, the server survives.
> I have backed up the database and copied it to an identical server and
> loaded the same data in and again that server reboots. However, if I copy
> the DB and the data to my PC (single 2.6 GHz p4 processor) it works fine.
> It also doesn't flat line at 100% cpu but instead the CPU follows a cyclic
> pattern. I can't get my PC to crash...
> Any ideas?
> Griff
>|||Griff,
Are you running Enterprise Edition or Standard Edition? Enterprise
Edition supports Parallel index creation. Maybe you hit a bug, and are
not running Enterprise Edition on your PC.
Needless to say you need to install the latest service packs. Some bugs
are fixed...
http://support.microsoft.com/default.aspx?scid=kb;EN-US;279295
Gert-Jan
GriffithsJ wrote:
> Dear all
> I have a table which contains ~ 11 million rows in it.
> I drop the indexes, bulk insert the data into it and then rebuild the
> indexes.
> Whilst building the indexes, the server (dual xeon 2.8 GHz) maxes out at
> 100 CPU on both processors for ~ 10 minutes and then the whole server
> re-boots There are 3 indexes to be built, it crashes whilst building the
> third.
> However, if I run the three steps one at a time, the server survives.
> I have backed up the database and copied it to an identical server and
> loaded the same data in and again that server reboots. However, if I copy
> the DB and the data to my PC (single 2.6 GHz p4 processor) it works fine.
> It also doesn't flat line at 100% cpu but instead the CPU follows a cyclic
> pattern. I can't get my PC to crash...
> Any ideas?
> Griff
--
(Please reply only to the newsgroup)

Indexing problem

Dear all
I have a table which contains ~ 11 million rows in it.
I drop the indexes, bulk insert the data into it and then rebuild the
indexes.
Whilst building the indexes, the server (dual xeon 2.8 GHz) maxes out at
100 CPU on both processors for ~ 10 minutes and then the whole server
re-boots There are 3 indexes to be built, it crashes whilst building the
third.
However, if I run the three steps one at a time, the server survives.
I have backed up the database and copied it to an identical server and
loaded the same data in and again that server reboots. However, if I copy
the DB and the data to my PC (single 2.6 GHz p4 processor) it works fine.
It also doesn't flat line at 100% cpu but instead the CPU follows a cyclic
pattern. I can't get my PC to crash...
Any ideas?
Griff
so there are really two question.
1. How to optimize an index build.
2. why is the server crashing. Anything in the logs (os or SQL). Any more
details?
Unqueestionably.. .THAT is a bug. Now, it might be a MS bug, or it might be
a hardware bug. If it's a MS bug and you open a call to MS product support
the call will be free. If it's a hardware bug (perhaps your server IO isn't
on the HCL?) then you'd end up eating the cost...
You might want to take a look at SQLIO from MS. I don't have the URL, but
it's an IO stress tool. It simulates SQL Server IO... it will mostly likely
cause the server to crash if in fact SQL IO stress is causing the server to
crash under an index build...
Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"GriffithsJ" <GriffithsJ_520@.hotmail.com> wrote in message
news:Oofq5o0PEHA.3420@.TK2MSFTNGP11.phx.gbl...
> Dear all
> I have a table which contains ~ 11 million rows in it.
> I drop the indexes, bulk insert the data into it and then rebuild the
> indexes.
> Whilst building the indexes, the server (dual xeon 2.8 GHz) maxes out at
> 100 CPU on both processors for ~ 10 minutes and then the whole server
> re-boots There are 3 indexes to be built, it crashes whilst building the
> third.
> However, if I run the three steps one at a time, the server survives.
> I have backed up the database and copied it to an identical server and
> loaded the same data in and again that server reboots. However, if I copy
> the DB and the data to my PC (single 2.6 GHz p4 processor) it works fine.
> It also doesn't flat line at 100% cpu but instead the CPU follows a cyclic
> pattern. I can't get my PC to crash...
> Any ideas?
> Griff
>
|||Griff,
Are you running Enterprise Edition or Standard Edition? Enterprise
Edition supports Parallel index creation. Maybe you hit a bug, and are
not running Enterprise Edition on your PC.
Needless to say you need to install the latest service packs. Some bugs
are fixed...
http://support.microsoft.com/default...b;EN-US;279295
Gert-Jan
GriffithsJ wrote:
> Dear all
> I have a table which contains ~ 11 million rows in it.
> I drop the indexes, bulk insert the data into it and then rebuild the
> indexes.
> Whilst building the indexes, the server (dual xeon 2.8 GHz) maxes out at
> 100 CPU on both processors for ~ 10 minutes and then the whole server
> re-boots There are 3 indexes to be built, it crashes whilst building the
> third.
> However, if I run the three steps one at a time, the server survives.
> I have backed up the database and copied it to an identical server and
> loaded the same data in and again that server reboots. However, if I copy
> the DB and the data to my PC (single 2.6 GHz p4 processor) it works fine.
> It also doesn't flat line at 100% cpu but instead the CPU follows a cyclic
> pattern. I can't get my PC to crash...
> Any ideas?
> Griff
(Please reply only to the newsgroup)

Friday, March 9, 2012

Indexes slowing down BULK INSERT

I've been doing some experiments with speeding up copying tables of
approximately 1 million rows between databases using BCP and BULK INSERT.

I noticed that the total time for removing the indexes (non-clustered) and
then recreating them after the BULK INSERT was significantly less than just
doing the BULK INSERT with the indexes left there, even though I specified
TABLOCK.

I would have expected SQL Server not to update the index until the insert
completed (given the table lock) and so removing the indexes would have no
effect. Can anyone explain why removing the indexes should speed it up?

This is on SQL Server 7.

Cheers
DaveDavid Sharp (no email address supplied) writes:
> I've been doing some experiments with speeding up copying tables of
> approximately 1 million rows between databases using BCP and BULK INSERT.
> I noticed that the total time for removing the indexes (non-clustered)
> and then recreating them after the BULK INSERT was significantly less
> than just doing the BULK INSERT with the indexes left there, even though
> I specified TABLOCK.
> I would have expected SQL Server not to update the index until the insert
> completed (given the table lock) and so removing the indexes would have no
> effect. Can anyone explain why removing the indexes should speed it up?

I have not studied this case very closely. But a few observations: if
you supplied a batch size with /b, SQL Server had no choice but to
maintain the indexes while loading, since each batch is committed
separately.

When running some bulk-loading recently, I notice that when loading on
a completely unindexed table, BCP reported the copied rows swiftly, and
then completely directly, whereas on indexed tables there was a delay
from when all rows had been loaded until the command had completed,
which I supposed was spent on rebuilding indexes. I did not use TABLOCK.

I should add that I was working on SQL 2000, and the behaviour I saw
may reflect an improvement from SQL7.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||"Erland Sommarskog" <sommar@.algonet.se> wrote in message
news:Xns941B1079D8D3Yazorman@.127.0.0.1...
> David Sharp (no email address supplied) writes:
> > I've been doing some experiments with speeding up copying tables of
> > approximately 1 million rows between databases using BCP and BULK
INSERT.
> > I noticed that the total time for removing the indexes (non-clustered)
> > and then recreating them after the BULK INSERT was significantly less
> > than just doing the BULK INSERT with the indexes left there, even though
> > I specified TABLOCK.
> > I would have expected SQL Server not to update the index until the
insert
> > completed (given the table lock) and so removing the indexes would have
no
> > effect. Can anyone explain why removing the indexes should speed it up?
> I have not studied this case very closely. But a few observations: if
> you supplied a batch size with /b, SQL Server had no choice but to
> maintain the indexes while loading, since each batch is committed
> separately.

I have studied this somewhat closely. :-)

And what Erland says about the /b is a critical part of it. We on a
quarterly basis have to load a multimillion set of rows. As an experiment
recently (to reconfirm my thoughts) I did a test load on a backup server.
It took I believe 3 days to do the load. This was without removing the
non-clustered indices first.

For the actual load I I removed the non-clustered indices (but kept the
clustered index since the data is BCP'd out of another table already in
order). This took well under 12 hours. (Actually not 100% sure how long it
took since I started it around midnight and the scripts finished sometime
before 9:00 AM). This included re-applying the indices to the table.

I don't know how much of a difference there would be if the data had been
completely unordered.

> When running some bulk-loading recently, I notice that when loading on
> a completely unindexed table, BCP reported the copied rows swiftly, and
> then completely directly, whereas on indexed tables there was a delay
> from when all rows had been loaded until the command had completed,
> which I supposed was spent on rebuilding indexes. I did not use TABLOCK.
> I should add that I was working on SQL 2000, and the behaviour I saw
> may reflect an improvement from SQL7.
> --
> Erland Sommarskog, SQL Server MVP, sommar@.algonet.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp

Wednesday, March 7, 2012

Indexes on SQL Server

Hi all,
I'm not au fait with indexes as much as I should be...
If a table has a lot of indexes (circa 18) and an insert is carried out
on this table roughly every 5 seconds, this is a bad thing isn't it?
i.e. you should only use this many indexes on tables where SELECT
statements are used, more than INSERTs
Also, when creating indexes for a reports table, is Profiler the best
application to decide on the indexes?
Finally, if I have a statement like:
SELECT * FROM Blah ORDER BY a, b, c
... should I create an index on (a, b, c) together ?
i.e. Should I use my ORDER BY statements as guidelines on which indexes
to use?
Thanks!
Peter
--
"I hear ma train a comin'
... hear freedom comin"Hi
Unually it is usually not the number of actions taken against the data, but
the performance of those actions that is important. You will compromise
insert performance with a heavily indexed table, but this may be acceptable
if something else is compromised by not having them.
For creating the indexes you can look at the query plan(s) for the commands
you wish to improve. Query Analyser is a good place to look at these. It is
also worth looking at the Index tuning wizard to see if it comes up with any
suggestions.
You may also want to look at
http://www.sql-server-performance.c...ion_english.asp to
remove unused indexes.
Other reading:
http://www.sql-server-performance.com/mr_indexing.asp
http://www.sql-server-performance.c..._statistics.asp
John
"Stimp" wrote:

> Hi all,
> I'm not au fait with indexes as much as I should be...
> If a table has a lot of indexes (circa 18) and an insert is carried out
> on this table roughly every 5 seconds, this is a bad thing isn't it?
> i.e. you should only use this many indexes on tables where SELECT
> statements are used, more than INSERTs
> Also, when creating indexes for a reports table, is Profiler the best
> application to decide on the indexes?
> Finally, if I have a statement like:
> SELECT * FROM Blah ORDER BY a, b, c
> ... should I create an index on (a, b, c) together ?
> i.e. Should I use my ORDER BY statements as guidelines on which indexes
> to use?
> Thanks!
> Peter
> --
> "I hear ma train a comin'
> ... hear freedom comin"
>|||On Fri, 27 May 2005 John Bell <jbellnewsposts@.h0tmail.com> wrote:
> You may also want to look at
> http://www.sql-server-performance.c...ion_english.asp to
> remove unused indexes.
> Other reading:
> http://www.sql-server-performance.com/mr_indexing.asp
> http://www.sql-server-performance.c..._statistics.asp
Thanks for the information!
Peter
--
"I hear ma train a comin'
... hear freedom comin"|||Every time insert or update changes a column that is included in an index,
that index is updated as well, so that's a performace hit. It is not
necessary to index every column used in the select's where or order clause.
For example, if you go the grocery store and ask the clerk where to find
canned corn, they will simply tell you isle number 3. They probably won't
tell you the shelf or slot number, becuase it would be too much trouble for
them to retain that level of detail in their memory, and besides the
additional information would only marginally decrease the time required for
your search.
"Stimp" <ren@.spumco.com> wrote in message
news:slrnd9dtab.s2m.ren@.carbon.redbrick.dcu.ie...
> Hi all,
> I'm not au fait with indexes as much as I should be...
> If a table has a lot of indexes (circa 18) and an insert is carried out
> on this table roughly every 5 seconds, this is a bad thing isn't it?
> i.e. you should only use this many indexes on tables where SELECT
> statements are used, more than INSERTs
> Also, when creating indexes for a reports table, is Profiler the best
> application to decide on the indexes?
> Finally, if I have a statement like:
> SELECT * FROM Blah ORDER BY a, b, c
> ... should I create an index on (a, b, c) together ?
> i.e. Should I use my ORDER BY statements as guidelines on which indexes
> to use?
> Thanks!
> Peter
> --
> "I hear ma train a comin'
> ... hear freedom comin"

Indexes on Bulk Insert data

Any help would be appreciated.

I am running a script that does the following in succession.

1-Drop existing database and create new database
2-Defines tables, stored procedures and functions in the database
3-Imports data using bulk insert
4-Analyzes data using stored procedures

I would like to improve the performance of the analysis in step 4 by
creating indexes in step 2.

Question 1-Are indexes updated when data is bulk inserted? I know they are
when using normal insert, update, or delete T-SQL but I am not sure about
bulk insert of data.

Question 2-Do I need to update the index statistics in any way or would they
be ready to use in step 4.

Thanks,
CJI would define step 4 as create indexes, that will have your stats up to
date and save you from any performance issues during the load or having
to reindex or update the stats

I would do the analysis in step five (depending what type of analysis)

HTH

Ray Higdon MCSE, MCDBA, CCNA

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||Chris (chris@.hrn.org) writes:
> 1-Drop existing database and create new database
> 2-Defines tables, stored procedures and functions in the database
> 3-Imports data using bulk insert
> 4-Analyzes data using stored procedures
> I would like to improve the performance of the analysis in step 4 by
> creating indexes in step 2.
> Question 1-Are indexes updated when data is bulk inserted? I know they are
> when using normal insert, update, or delete T-SQL but I am not sure about
> bulk insert of data.

Yes, they are. However, you may prefer to wait with creating indexes until
you have loaded the data for best performance. You may also opt to create
clustered indexes before bulk-loading and add non-clustered indexes after.
This is particularly appealing if the order in the data files corre-
sponds to the clustered indexes.

> Question 2-Do I need to update the index statistics in any way or would
> they be ready to use in step 4.

If you create indexes after bulk-loading, SQL Server will create statistics
for you when creating the indexes.

If you create indexex before bulk-loading, the statistics will not be
correct after the load. Thus, it can be a good idea run UPDATE STATISTICS
in this situation. However, if you don't, SQL Server will auto-update
statistics, unless you have turned off this feature.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp