Showing posts with label requirement. Show all posts
Showing posts with label requirement. Show all posts

Sunday, March 11, 2012

Bulk insert from text file in to multiple table

Hi,
I have a requirement, i need to bulk insert the data form the text file.
we need to insert firt 2 values from text file and insert into first
table.
then retrive the primary key value of inserted values then with this
value as Forign key insert next 4 value from the text file.
is there any way we can do it in bulk insert.
thanks,
prabhudeva.K
*** Sent via Developersdex http://www.examnotes.net ***> then retrive the primary key value of inserted values then with this
> value as Forign key insert next 4 value from the text file.
> is there any way we can do it in bulk insert.
No, you can't retrieve data with a bulk insert technique. This is one of
the downsides in using IDENTITY as a surrogate key.
If you must have a surrogate key rather than a natural one, you could use
uniqueidentifier instead and assign the GUID value in application code
before the bulk insert. That way, you'll know the PK value for the related
inserts. The downside is that the storage size is larger and the assigned
values will be basically random, which can reduce insert performance with
large tables. You can address the random issue by using
UuidCreateSequential instead of UuidCreate in app code.
Hope this helps.
Dan Guzman
SQL Server MVP
"Prabhudeva Kenganavara" <rekhaprabhudeva@.gmail.com> wrote in message
news:uhM6rYflGHA.2180@.TK2MSFTNGP05.phx.gbl...
> Hi,
> I have a requirement, i need to bulk insert the data form the text file.
> we need to insert firt 2 values from text file and insert into first
> table.
> then retrive the primary key value of inserted values then with this
> value as Forign key insert next 4 value from the text file.
> is there any way we can do it in bulk insert.
> thanks,
> prabhudeva.K
> *** Sent via Developersdex http://www.examnotes.net ***

Sunday, February 19, 2012

BULK DELETE ON SQL SERVER

We have a requirement to delete 20 million rows from a table A
containing 21 million rows
and insert 800,000 rows into table A from another table B.
We are getting the message:
Server: Msg 9002, Level 17, State 2, Line 1
The transaction log for database 'ledgerdb' is full. To find out why
space in the log cannot be reused, see the log_reuse_wait_desc column
in sys.databases
Server
Is there any way to do this deletion of 20 million rows out of 21
million rows in SQL server 2005 without writing log data?
Regards
Rajagopal NSHi
SELECT INTO ... FROM originaltable WHERE ...1mln rows to remain
DROP original table that nopw contains 20 mln rows. Rename a new created
table to original.
<rajagopal.ns@.gmail.com> wrote in message
news:1188982556.629589.151750@.19g2000hsx.googlegroups.com...
> We have a requirement to delete 20 million rows from a table A
> containing 21 million rows
> and insert 800,000 rows into table A from another table B.
> We are getting the message:
> Server: Msg 9002, Level 17, State 2, Line 1
> The transaction log for database 'ledgerdb' is full. To find out why
> space in the log cannot be reused, see the log_reuse_wait_desc column
> in sys.databases
> Server
> Is there any way to do this deletion of 20 million rows out of 21
> million rows in SQL server 2005 without writing log data?
> Regards
> Rajagopal NS
>|||You also may want to change the Recovery Model to "Bulk Log" while
performing this operation.
Or, you may change it to Simple Recovery Model and after the operation to
FULL model again. Otherwise, your ldf file may blow up :)
--
Ekrem Önsoy
<rajagopal.ns@.gmail.com> wrote in message
news:1188982556.629589.151750@.19g2000hsx.googlegroups.com...
> We have a requirement to delete 20 million rows from a table A
> containing 21 million rows
> and insert 800,000 rows into table A from another table B.
> We are getting the message:
> Server: Msg 9002, Level 17, State 2, Line 1
> The transaction log for database 'ledgerdb' is full. To find out why
> space in the log cannot be reused, see the log_reuse_wait_desc column
> in sys.databases
> Server
> Is there any way to do this deletion of 20 million rows out of 21
> million rows in SQL server 2005 without writing log data?
> Regards
> Rajagopal NS
>