November 30, 2010 at 10:08 pm
I have following text file
Ap1236
MH5698
TM2136
I have following table
CREATE TABLE Bulk_Insert_Test
(
State nvarchar(50)
,Number nvarchar(50)
)
my requirement is while bulk Insert from text file to table
I need to get following records.
State Number
AP 1236
MH 5698
TM 2136
What can I use for Field Terminator and row Terminator.
can any one give solution please.
Thanks,
IRK
December 1, 2010 at 7:12 am
For this, I would bulk insert into a one column staging table (you should use a staging table anyway to do validations on the data before inserting into the permanent table).
Then use left(col1,2) and substring(col1,3,50) to put the data into the separate fields in the permanent table.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply