How to add a carriage return

  • Hi All,

    I want to know whether a carriage return can be added for a column data, to show up 2 values one after the other (for example word wrap which automatically adjusts the text to the next line), when selected.

    For example, by mistake a user submits 2 times (may be slightly different in their millisecond values) like 08:24 and 08:25.

    Here the data will be looking as

    User Time Status

    ---- ----- ------

    xyz 08:24 Office Time In

    xyz 08:25 Office Time In

    abc 08:26 Office Time In

    bbc 08:27 Office Time In

    My ultimate requirement is to show up these values in a single row when selected should be like

    User Time Status

    ---- ---- ------

    xyz 08:24 Office Time In

    08:25

    abc 08:26 Office Time In

    bbc 08:27 Office Time In

    Overall, i should get only 3 rows as against 4 rows of data.

    Any help would be highly appreciated as i have to implement the same for different status types.

    Ravi


    Lucky

  • If you just need info on CR or CRLF,

    then maybe something like:

    SET @NewString = @Str1 + Char(13) + Char(10) + @Str2



    Once you understand the BITs, all the pieces come together

  • If I understand your need, this is difficult in T-SQL but easy in any programmable front-end. If you can't manage this on the front-end, then perhaps just using some aggregate functions would suffice; i.e. instead of listing the times, just return the first time and the number of total like submissions:

    
    
    SELECT [User], MIN([Time]) FirstPunch, COUNT(*) Punches, Status
    FROM TodaysPunches
    GROUP BY [User], Status
    ORDER BY FirstPunch, [User]

    --Jonathan



    --Jonathan

Viewing 3 posts - 1 through 2 (of 2 total)

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