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/