SQL Server Performance

Missing Row Delimeter in .txt file

Discussion in 'SQL Server 2008 General Developer Questions' started by rohaandba, Feb 28, 2011.

  1. rohaandba New Member

    I have a .txt file, I am suppose to put the data in the .txt file into a table in a database.
    I generally deal such type of task using Import Export Wizard (or) SSIS.
    But in this perticular .txt file there is no row delimeter "{CR}{LF}".
    Can any one suggest me the ways to put the row delimeter "{CR}{LF}" after every 40 charecters (As per the Spects) in that .txt file.
    So that I can load the data into the Data Base Table.
  2. ismailadar New Member

    Hi,
    Maybe you can insert file content to a temp table and use this script in order to delimit content and insert it into another table.declare
    @content varchar(1000)='I generally deal such type of task using Import Export Wizard (or) SSIS I generally deal such type of task using Import Export Wizard (or) SSIS I generally deal such type of task using Import Export Wizard (or) SSIS'declare
    @counter int=LEN(@content)/40+1
    declare @c int=0while
    (@counter>0)
    begin
    select SUBSTRING(@content,@c*40,40)
    set @c=@c+1
    set @counter=@counter-1end
  3. mmarovic Active Member

    How about using fixed length format instead of delimited?
  4. satya Moderator

    If the referred columns in the text file stands same without having any changes...then you can follow the suggested fix above.
    Also when you are trying to import from the text file you can refer the PREVIEW to see whether correct data is imported.

Share This Page