Results 1 to 8 of 8

Thread: String concat

  1. #1
    Join Date
    Jan 2003
    Location
    The Netherlands
    Posts
    149

    Question Unanswered: String concat

    Hello,

    I have a string let's say: "1\n2\n3".
    I want to convert it to:
    -- Start SqlServer
    BEGIN
    {CALL DBA.applsp_ChangeComments( 'ArtPurchPriceUpdate', 'TRIGGER', 'nl', 'ArtPurchPriceUpdate', '1' + CHAR(13)+ CHAR(10) +
    '2' + CHAR(13) + CHAR(10) +
    3' )}
    END;
    -- End SqlServer

    -- Start Sybase
    BEGIN
    CALL DBA.applsp_ChangeComments( 'ArtPurchPriceUpdate', 'TRIGGER', 'nl', 'ArtPurchPriceUpdate', '1' + CHAR(13) + CHAR(10) +
    '2' + CHAR(13) + CHAR(10) +
    '3' );
    END;
    -- End Sybase

    -- Start Oracle
    BEGIN
    ish.applsp_ChangeComments( 'ArtPurchPriceUpdate', 'TRIGGER', 'nl', 'ArtPurchPriceUpdate', '1' || CHR(13) || CHR(10) ||
    '2' || CHR(13) || CHR(10) ||
    '3' );
    END;
    /
    -- End Oracle

    This works well for oracle and sybase, for sqlserver I can't concatenate in a parameter of a stored procedure. I really want to do this. To create a variable is a lot of extra programming. Is there anyone who knows how to cancat these strings within the stored procedure call?

    thanks beforehand,

    Coen Dunnink
    The Netherlands

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Coen

    Assuming the missing quotation mark before the 3 is a paste error...

    Does the below shed some light?
    Code:
    PRINT ASCII('n')
    PRINT ASCII('\')
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Jan 2003
    Location
    The Netherlands
    Posts
    149

    Still can't use

    Still can't use it in one stored procedure call

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Eh? Use what?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Jan 2003
    Location
    The Netherlands
    Posts
    149

    Re Use what

    Can't use PRINT ASCII('n') in a parameter of a stored procedure.

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Ah - no -

    My point was run that in Query Analyser - the results will be illuminating. Or to put it another way:
    CHAR(13) is a Carriage Return Line feed
    CHAR(10) is a Line Feed
    To prove this - run the below in query analsyer too:
    Code:
    PRINT '1' + CHAR(13)+ CHAR(10) + '2' + CHAR(13) + CHAR(10) + '3'
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Jul 2003
    Posts
    123
    I think he meant that you should run the PRINT ASCII in the query analyser and find out that ASCII för 'n' and '\' is 110, 92 and not 13, 10

    PRINT ASCII('n') -> 110
    PRINT ASCII('\') -> 92

  8. #8
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    Or just use 0x0D0A

    -- This is all just a Figment of my Imagination --

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •