Labels

Friday, December 30, 2011

Importing Flat File into a Table

CREATE TABLE #stgImportFlatfile (
Record  varchar(256) null) 
GO 

CREATE TABLE stgImportFlatfile (
ID int identity(1,1) primary key,
Record  varchar(256) null) 
GO 

BULK INSERT #stgImportFlatfile
FROM 'F:\data\import\ProductBulk.txt'
GO

DELETE #stgImportFlatfile WHERE Record is null
              GO

INSERT stgImportFlatfile(Record)
SELECT * FROM #stgImportFlatfile
GO

SELECT * from stgImportFlatfile
GO 

DROP TABLE #stgImportFlatfile
GO
-- DROP TABLE stgImportFlatfile
GO

No comments:

Post a Comment