Tags: carriage, create, embed, feed, field1, field2, field3, fields, inside, line, programming, return, sql, string, variable

Create a string with carriage return and line feed

On Programmer » SQL

2,943 words with 4 Comments; publish: Thu, 29 May 2008 02:58:00 GMT; (20046.88, « »)

Hello,

Is it possible to create a variable that has carriage return and line feed

embed inside. Say I have 3 fields: field1, field2, field3. I want to return a

string with carriage returns and line feeds between field1, 2 and field2, 3.

Thanks in advance

All Comments

Leave a comment...

  • 4 Comments
    • LOOK in BOL for CHAR,

      TAB Char(9)

      LineFeed Char(10)

      CarriageReturn Char(13)

      HTH, Jens Süßmeyer.

      --

      http://www.sqlserver2005.de

      --

      "Ed Chiu" <EdChiu.sql.todaysummary.com.discussions.microsoft.com> schrieb im Newsbeitrag

      news:462D3FCC-28E9-4660-A5F7-559D5CB3CA33.sql.todaysummary.com.microsoft.com...

      > Hello,

      > Is it possible to create a variable that has carriage return and line feed

      > embed inside. Say I have 3 fields: field1, field2, field3. I want to

      > return a

      > string with carriage returns and line feeds between field1, 2 and field2,

      > 3.

      > Thanks in advance

      #1; Thu, 29 May 2008 03:00:00 GMT
    • > Is it possible to create a variable that has carriage return and line feed

      > embed inside. Say I have 3 fields: field1, field2, field3. I want to

      return a

      > string with carriage returns and line feeds between field1, 2 and field2,

      3.

      Include CHAR(13)+CHAR(10) when you are concatenating the strings.

      --

      Dejan Sarka, SQL Server MVP

      Associate Mentor

      www.SolidQualityLearning.com

      #2; Thu, 29 May 2008 03:01:00 GMT
    • Try,

      select 'Microsoft' + char(13) + char(10) + 'SQL' + char(13) + char(10) +

      'Server' + char(13) + char(10) + '2000'

      AMB

      "Ed Chiu" wrote:

      > Hello,

      > Is it possible to create a variable that has carriage return and line feed

      > embed inside. Say I have 3 fields: field1, field2, field3. I want to return a

      > string with carriage returns and line feeds between field1, 2 and field2, 3.

      > Thanks in advance

      #3; Thu, 29 May 2008 03:02:00 GMT
    • DECLARE .sql.todaysummary.com.var VARCHAR(50)

      SET .sql.todaysummary.com.var = 'joe' + CHAR(13) + CHAR(10) + 'blow'

      SELECT .sql.todaysummary.com.var

      It's up to the consumer of the data to display it properly. For example

      in Query Analyzer, if you choose to display results in a grid, it

      replaces the carriage return, line feed with spaces. If you choose to

      display in text mode, it'll put the carriage return, line feed in there

      for you.

      If you're returning this to a .net dataset, you can display it properly.

      HTH...

      Joe Webb

      SQL Server MVP

      ~~~

      Get up to speed quickly with SQLNS

      http://www.amazon.com/exec/obidos/tg/detail/-/0972688811

      Ed Chiu wrote:

      > Hello,

      > Is it possible to create a variable that has carriage return and line feed

      > embed inside. Say I have 3 fields: field1, field2, field3. I want to return a

      > string with carriage returns and line feeds between field1, 2 and field2, 3.

      > Thanks in advance

      #4; Thu, 29 May 2008 03:03:00 GMT