Thursday, June 19, 2014

Read text file in sql server

Method 1:

BULK
INSERT dbo.BrandAAIA
FROM 'D:\data work\ParentSupplierBrand\ParentSupplierBrand.txt'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
GO

=========================================================
Method 2:
create table #FileContents
(
    LineContents  nvarchar(max)
);

insert into #FileContents
select f.BulkColumn
    from openrowset
    (
        bulk 'D:\data work\ParentSupplierBrand\ParentSupplierBrand.txt',
        SINGLE_CLOB
    ) f;

select * from #FileContents;
DROP TABLE #FileContents

No comments:

Post a Comment

Opps Part 1 : Abstraction

  Abstraction in C# is a fundamental concept of object-oriented programming (OOP) that allows developers t...