June 26, 2009 at 1:40 am
Hi,
Anyone can help me, on how to insert a RAW Data to a Table with selected columns. I need only the Column1 and Column3 to be inserted. Thanking you.
TextFile : RawData.CSV
----------------------
Column1,Column2,Column3
1111111,AAAAAA,BBBBBBB
2222222,AAAAAA,BBBBBBB
3333333,XXXXXX,CCCCCC
Table : RAWDATA
-----------------
Column1 int,
Column2 varchar(10),
Column3 varchar(10),
Regards,
FPalero
June 30, 2009 at 11:01 am
You can bulk insert into a temporary table and then select the columns you desire. Here is an example:
DECLARE @TempTable TABLE
(
Column1 INT,
Column2 VARCHAR(10),
Column2 VARCHAR(10)
)
BULK INSERT @TempTable FROM 'Filepath'
SELECT Column1, Column2
FROM @TempTable
As an alternative, I believe that you can use a format file to bulk insert directly into your desired table.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy