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

📱Build WhatsApp Bot using .NET + OpenAI

   In this article, you will learn how to build a real-world WhatsApp chatbot using ASP.NET Core and OpenAI. This bot can automatically repl...