Quản trị net diễn đàn chia sẻ thông tin các thủ thuật mạng, internet bảo mật thông tin dành cho giới IT VIệt hy vọng là nơi bổ ích cho cộng đồng

Quản trị net diễn đàn chia sẻ thông tin các thủ thuật mạng, internet bảo mật thông tin dành cho giới IT VIệt hy vọng là nơi bổ ích cho cộng đồng (http://quantrinet.com/forum/index.php)
-   Mssql( Microsoft SQL Server) (http://quantrinet.com/forum/forumdisplay.php?f=152)
-   -   Hướng dẫn cách Import, Export Table nhanh nhất (Bulk Insert) (http://quantrinet.com/forum/showthread.php?t=9938)

hoctinhoc 29-10-2015 06:05 AM

Hướng dẫn cách Import, Export Table nhanh nhất (Bulk Insert)
 
Hướng dẫn cách Import, Export Table nhanh nhất

Có 3 cách Import, Export dữ liệu của Table

1. Insert

INSERT INTO TABLE2 SELECT * FROM TABLE1

2. Cách Import và Export bằng Wizard


3. Cách nhanh nhất là Bulk Insert


- Enable

How to Enable XP_CMDSHELL using SP_CONFIGURE

Trích dẫn:

Use Master
GO

EXEC master.dbo.sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO

EXEC master.dbo.sp_configure 'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE
GO




Export table tên là FirstTable ra file csv , IBM2 là tên Server



Trích dẫn:


execute xp_cmdshell 'bcp ShrinkIsBed.dbo.FirstTable out c:\temp\FirstTable.csv -SIBM2 -T -n'


Import vào lại chính table FirstTable


Trích dẫn:

bulk insert ShrinkIsBed.dbo.FirstTable from 'c:\temp\FirstTable.csv'
with (DATAFILETYPE = 'native')


Import vào Table mới (tạm table SecondTable và import file vào)


Trích dẫn:

select * into ShrinkIsBed.dbo.SecondTable from ShrinkIsBed.dbo.FirstTable where 1=2 bulk insert ShrinkIsBed.dbo.FirstTable from 'c:\temp\FirstTable.csv'
with (DATAFILETYPE = 'native')


===================
1 vài Option chọn khi Import

with (DATAFILETYPE = 'native')

FIELDTERMINATOR = '^',

ROWTERMINATOR= '0x0a');

===================

http://www.databasejournal.com/featu...to-Another.htm


http://www.mytechmantra.com/LearnSQL...-SP_CONFIGURE/


Bây giờ là 03:54 PM. Giờ GMT +7

Diễn đàn tin học QuantriNet
quantrinet.com | quantrimang.co.cc
Founded by Trương Văn Phương | Developed by QuantriNet's members.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.