Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Inserting RAW Data to Table with selected columns Expand / Collapse
Author
Message
Posted Friday, June 26, 2009 1:40 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 06, 2009 12:51 AM
Points: 1, Visits: 29
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
Post #742430
Posted Tuesday, June 30, 2009 11:01 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, April 02, 2010 6:41 AM
Points: 54, Visits: 134
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.
Post #744672
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse