top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to Import Data from Note Pad Files to Sql Server 2008 using PL-Sql?

0 votes
329 views
How to Import Data from Note Pad Files to Sql Server 2008 using PL-Sql?
posted Mar 19, 2016 by Sathyasree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

For Import Data we need First of All Format File. Format File is a file in which you explain your columns, their data Type and also their delaminate Sign like ‘-’.

After that we have to Create table in sql Server 2008 with respect to format File as describe in following PL-SQL Querry.

Create table Temp
{
[Column1] as Varchar(200),
[Column2] as Varchar(200),
[Column3] as varchar(200),
[Column4] as varchar(200)
}

After that Set each Column Data Type varchar because while importing txt File we don’t want errors related to data type conversions.

So now write the following final Query.

INSERT INTO [tblTemp]
                       ([Column1], [Column2], [Column3], [Column4])

SELECT    A.[Column1], A.[Column2], A.[Column3], A.[Column4]
FROM OPENROWSET (BULK 'D:\Test_Data.txt',

FORMATFILE = 'D:\Test_Data.fmt') AS A;
answer Mar 19, 2016 by Shivaranjini
...