0

I have a question about Bulk Insert query. I have a file which contains the following format

| |Test|test1|test2|
| | a  | b   |  c  | 
| | d  | e   | f   |

I use in sql the following code. I can skip the first row by using firstow=2 but is there something to ignore the first three characters from each row?

 SET @s = N'BULK INSERT ' + @t + '   FROM ''' + @f + '''
  WITH ( FIELDTERMINATOR = ''|''  ,ROWTERMINATOR = ''0x0a'',FIRSTROW=2 )'

In power shell you have something like this. Is there also something to ignore the first three characters?

  $columns = Get-Content $full | Select-Object -First 1
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
MBurger
  • 53
  • 3
  • 6
  • I recommend loading the data into a staging table and then moving the data to the final location. This gives you the opportunity to fix types and adjust values. – Gordon Linoff Aug 11 '17 at 11:57
  • Is there no other option like firstcharacter=3? because i need to import many files. To manually import it everytime is not really handy – MBurger Aug 11 '17 at 11:58
  • Possible duplicate of [Ignore certain columns when using BULK INSERT](https://stackoverflow.com/questions/14711814/ignore-certain-columns-when-using-bulk-insert) – Alex Aug 11 '17 at 12:06

0 Answers0