Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How can i get this,using bulk insert file format

Author  Topic 

sathishmangunuri
Starting Member

32 Posts

Posted - 2010-11-30 : 23:58:32
I have following text file

101,Ap1236,red
102,MH5698,white
103,TM2136,green

I have following table

CREATE TABLE CARNUMBER
(
[No] int
,State nvarchar(50)
,Number nvarchar(50)
,Color varchar(20)
)
i have created default format file for the above table.

but how can i modify this format file such that i should get 1st field data into 1st col and 2nd field data should split into 2 parts ex AP1236 as AP and 1236 and Ap should goes into 2nd col and 1236 into 3rd col,and 3rd field should go into 4th col of table.

can any one give solution please.


Thanks,
sat.


madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-12-01 : 02:20:07
1 Import data to a staging table that has three columns
2 From the staging table, insert into target table by splitting the second column's value

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-12-01 : 13:12:10
or you need to use some ETL tool like SSIS and do the transformation inside it

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -