Click here to Skip to main content
11,484,162 members (69,372 online)
Rate this: bad
good
Please Sign up or sign in to vote.
How to add multiline text in sql server 2005 ?
I have a reviews column to store reviews, so i need to store multi line text, how could i do this ?
Thanks!
Posted 27-Apr-13 22:22pm
Edited 27-Apr-13 22:32pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

select 'hello' + char(13) + char(10) + 'world'
/*
 
------------
hello
world
 
(1 row(s) affected)
 

*/ 
Look for CHAR in Books Online.

Hope this helps,
Pablo.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

But i have to insert paragraphs ??
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Easy: just use a parameterized query - you should be doing it anyway to avoid SQL Injection attacks:
string lines = "line1\nline2";
Or
string[] data = {"line1", "line2"};
string lines = string.Join("\n", data);
Then:
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand com = new SqlCommand("INSERT INTO myTable (multiLineTextColumn) VALUES (@MLT)", con))
        {
        com.Parameters.AddWithValue("@MLT", lines);
        com.ExecuteNonQuery();
        }
    }
  Permalink  
Comments
Member 9898508 at 28-Apr-13 12:20pm
   
Thnks for ur advice .But let me expalin my problem . I have a reviews page for which user can read reviews and write reviews . so now whenever a user clicks a product the reviews stored in data base should be displayed and user can also write a review, which should be stored in data base..Now how can i store those big reviews in sql 2005 and how to display them in web page ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Thnks for ur advice .But let me expalin my problem . I have a reviews page for which user can read reviews and write reviews . so now whenever a user clicks a product the reviews stored in data base should be displayed and user can also write a review, which should be stored in data base..Now how can i store those big reviews in sql 2005 and how to display them in web page ?
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 210
1 Frankie-C 155
2 Raje_ 155
3 OriginalGriff 147
4 Maciej Los 110
0 Sergey Alexandrovich Kryukov 8,489
1 OriginalGriff 7,943
2 Sascha Lefèvre 3,114
3 Maciej Los 2,581
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 28 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100