• Ectualy you don't need to name the columns in the select statement, so you can still use 2 replace statements and it will work. You can check the code bellow that inserts the data into the table

    Create table DataFiles(IdData int identity(1,1) primary key,

    server nvarchar(4000),domain nvarchar(50),

    ReceivedFilescount int,DateReceived date,

    company varchar(50),ExpectedFilesCount int)

    declare @SQL varchar(max)

    declare @MyString varchar(max) =

    '2D5E558D4B5A3D4F962DA5051EE364BE06CF37A3A5@Server.com|user1@domain1.com|0|2014-02-05|Microsoft|100

    E52F650C53A275488552FFD49F98E9A6BEA1262E@Server.com|user2@domain2.com|1|2014-03-05|Samsumg|120

    4fd70c47.4d600e0a.0a7b.ffff87e1@Server.com|user3@domain3.com|2|2014-01-05|Nokia|139

    4fd70c47.4d600e0a.0a7b.ffff87e1@Server.com|user4@domain4.com|3|2014-02-08|HTC|149

    4fd70c47.4d600e0a.0a7b.ffff87e1@Server.com |user5@domain5.com|4|2014-02-13|Paypal|129'

    select @MyString = 'SELECT ''' +replace(replace(@MyString,'|',''','''),'

    ',''' union select

    ''') + ''''

    select @MyString

    exec (@MyString)

    set @SQL = 'INSERT INTO DataFiles(server, domain, ReceivedFilescount, DateReceived, company, ExpectedFilesCount)

    ' + @MyString

    exec (@SQL)

    select * from DataFiles

    Although the code works, I think that you should look on working with bulk insert statement or BCP. In my opinion it is more suitable then using my code.

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/