Split String with row terminator

  • Hi MM,

    I am sorry that am bid confused about the issue. You meant to say the issue is with my sample data or the where condition ? what could be the remedy to the issue. can you please post the sql.

    This is my full sql.

    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 ALL select

    ''') + ''''

    WHERE @MyString NOT LIKE '%[^-a-zA-Z0-9@|.'+CHAR(10)+CHAR(13)+']%'

    --select @MyString

    --exec (@MyString)

    print @MyString

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

    ' + @MyString

    exec (@SQL)

    Thanks

  • The problem is in your sample data at position 407 (highlighted below - unfortunately it is not visible, but that character is the problem)

    Delete that one character from your data and it will work...

    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[highlight="#ffff11"] [/highlight]|user5@domain5.com|4|2014-02-13|Paypal|129

    ------------------------------------------^

    MM



    select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);

  • Forum Etiquette: How to post Reporting Services problems
  • [/url]
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • [/url]
  • How to Post Performance Problems - by Gail Shaw
  • [/url]

  • Great. It is invisible to me. Thank you for notifying this. It works now. Appreciate your time on this MM.

    Thank you jeff and Adi for this wonderful post with great query. I am going to try with bulk insert from my front end as well as this query, for measuring the performance.

  • Viewing 3 posts - 16 through 17 (of 17 total)

    You must be logged in to reply to this topic. Login to reply